for (i = 0; i < entries; i++) {
struct stat st;
- unsigned int oldmode, mode;
+ unsigned int oldmode;
struct cache_entry *ce = active_cache[i];
int changed;
continue;
oldmode = ntohl(ce->ce_mode);
- mode = (S_ISLNK(st.st_mode) ? S_IFLNK :
- S_IFREG | ce_permissions(st.st_mode));
-
- show_modified(oldmode, mode, ce->sha1, null_sha1,
+ show_modified(oldmode, DIFF_FILE_CANON_MODE(st.st_mode),
+ ce->sha1, null_sha1,
ce->name);
}
diffcore_std((1 < argc) ? argv + 1 : NULL,
int len = strlen(tree)+1;
const unsigned char *sha1 = tree + len;
const char *path = strchr(tree, ' ');
+ unsigned int mode;
- if (!path || size < len + 20 || sscanf(tree, "%o", modep) != 1)
+ if (!path || size < len + 20 || sscanf(tree, "%o", &mode) != 1)
die("corrupt tree file");
*pathp = path+1;
+ *modep = DIFF_FILE_CANON_MODE(mode);
return sha1;
}
else if (memcmp(p->one->sha1, p->two->sha1, 20) ||
p->one->mode != p->two->mode)
p->status = 'M';
- else
- /* this is a "no-change" entry.
- * should not happen anymore.
- * p->status = 'X';
+ else {
+ /* This is a "no-change" entry and should not
+ * happen anymore, but prepare for broken callers.
*/
- die("internal error in diffcore: unmodified entry remains");
+ error("feeding unmodified %s to diffcore",
+ p->one->path);
+ p->status = 'X';
+ }
}
diff_debug_queue("resolve-rename-copy done", q);
}
#ifndef DIFF_H
#define DIFF_H
+#define DIFF_FILE_CANON_MODE(mode) \
+ (S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
+ S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
+
extern void diff_addremove(int addremove,
unsigned mode,
const unsigned char *sha1,
#define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
-#define DIFF_FILE_CANON_MODE(mode) \
- (S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
- S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
-
extern void diff_free_filepair(struct diff_filepair *);
extern int diff_unmodified_pair(struct diff_filepair *);