summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c43ce6d)
raw | patch | inline | side by side (parent: c43ce6d)
author | Junio C Hamano <junkio@cox.net> | |
Thu, 3 Aug 2006 19:01:01 +0000 (12:01 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 3 Aug 2006 21:41:53 +0000 (14:41 -0700) |
The final output from diff used to compare pathnames between
preimage and postimage to tell if the filepair is a rename/copy.
By explicitly marking the filepair created by diffcore_rename(),
the output routine, resolve_rename_copy(), does not have to do
so anymore. This helps feeding a filepair that has different
pathnames in one and two elements to the diff machinery (most
notably, comparing two blobs).
Signed-off-by: Junio C Hamano <junkio@cox.net>
preimage and postimage to tell if the filepair is a rename/copy.
By explicitly marking the filepair created by diffcore_rename(),
the output routine, resolve_rename_copy(), does not have to do
so anymore. This helps feeding a filepair that has different
pathnames in one and two elements to the diff machinery (most
notably, comparing two blobs).
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c | patch | blob | history | |
diffcore-rename.c | patch | blob | history | |
diffcore.h | patch | blob | history |
index 607c357f5ad8ff07c69dec7c185d667db4e43397..895c1376559cc2aaa1e6c25361a9a6b831c9a18a 100644 (file)
--- a/diff.c
+++ b/diff.c
struct diff_filespec *one,
struct diff_filespec *two)
{
- struct diff_filepair *dp = xmalloc(sizeof(*dp));
+ struct diff_filepair *dp = xcalloc(1, sizeof(*dp));
dp->one = one;
dp->two = two;
- dp->score = 0;
- dp->status = 0;
- dp->source_stays = 0;
- dp->broken_pair = 0;
if (queue)
diff_q(queue, dp);
return dp;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 1de8d32502a77b641e004e9df9da3fcc188eef9c..0ec488a9033ea2d4514dab450d9e20581782ddbb 100644 (file)
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
fill_filespec(two, dst->sha1, dst->mode);
dp = diff_queue(NULL, one, two);
+ dp->renamed_pair = 1;
if (!strcmp(src->path, dst->path))
dp->score = rename_src[src_index].score;
else
diff --git a/diffcore.h b/diffcore.h
index 73c7842cc7fd907519016b936a96b6f08cd80b47..2249bc2c05744ce5026744547fcb30195a19b3f1 100644 (file)
--- a/diffcore.h
+++ b/diffcore.h
char status; /* M C R N D U (see Documentation/diff-format.txt) */
unsigned source_stays : 1; /* all of R/C are copies */
unsigned broken_pair : 1;
+ unsigned renamed_pair : 1;
};
#define DIFF_PAIR_UNMERGED(p) \
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
-#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
+#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
#define DIFF_PAIR_BROKEN(p) \
( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \