summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 81bb573)
raw | patch | inline | side by side (parent: 81bb573)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 1 Jun 2005 18:38:07 +0000 (11:38 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Wed, 1 Jun 2005 20:24:03 +0000 (13:24 -0700) |
The core GIT repository has trees that record regular file mode
in 0664 instead of normalized 0644 pattern. Comparing such a
tree with another tree that records the same file in 0644
pattern without content changes with git-diff-tree causes it to
feed otherwise unmodified pairs to the diff_change() routine,
which triggers a sanity check routine and barfs. This patch
fixes the problem, along with the fix to another caller that
uses unnormalized mode bits to call diff_change() routine in a
similar way.
Without this patch, you will see "fatal error" from diff-tree
when you run git-deltafy-script on the core GIT repository
itself.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
in 0664 instead of normalized 0644 pattern. Comparing such a
tree with another tree that records the same file in 0644
pattern without content changes with git-diff-tree causes it to
feed otherwise unmodified pairs to the diff_change() routine,
which triggers a sanity check routine and barfs. This patch
fixes the problem, along with the fix to another caller that
uses unnormalized mode bits to call diff_change() routine in a
similar way.
Without this patch, you will see "fatal error" from diff-tree
when you run git-deltafy-script on the core GIT repository
itself.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff-files.c | patch | blob | history | |
diff-tree.c | patch | blob | history | |
diff.c | patch | blob | history | |
diff.h | patch | blob | history | |
diffcore.h | patch | blob | history |
diff --git a/diff-files.c b/diff-files.c
index f3a79e5c03676f340424913a354d35a9c5c61554..3b05497a8573427f28a00e86fa4f2bf7bf920e74 100644 (file)
--- a/diff-files.c
+++ b/diff-files.c
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,
diff --git a/diff-tree.c b/diff-tree.c
index db37aa714f0d0a7b0b2437ffb5b04351642f1e00..a6d358fb34cdae32917bd08ab8d3f7bb2d10f3a7 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -44,10 +44,12 @@ static const unsigned char *extract(void *tree, unsigned long size, const char *
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;
}
index d7cde8fa056d5f83fe7b97ce44b6c86b87201f80..7cf40daee5f2f7317b1c7558428f5dd184b68a67 100644 (file)
--- a/diff.c
+++ b/diff.c
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);
}
index 0f1ed5877a9151bfd1b8146f949900eb0831248a..3fcf7010e38913a697c927882895984248b9f805 100644 (file)
--- a/diff.h
+++ b/diff.h
#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,
diff --git a/diffcore.h b/diffcore.h
index dc0f21db9bb7150cf0071b37ffa74b2175590bba..981ee052d7f3962c18356b4e0e9c82cb4b4f5f17 100644 (file)
--- a/diffcore.h
+++ b/diffcore.h
#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 *);