diff.c: do not use pathname comparison to tell renames
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>
Junio C Hamano committed
Aug 3, 2006 at 12:01 UTC
ef677686efe1868432d3cc9d4c41a93b44f3def8
3 files changed
+4
-6
diff.c
+1
-5
@@ -1786,13 +1786,9 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
1786
struct diff_filespec *one,
1787
struct diff_filespec *two)
1788
{
1789
- struct diff_filepair *dp = xmalloc(sizeof(*dp));
1789
+ struct diff_filepair *dp = xcalloc(1, sizeof(*dp));
1790
dp->one = one;
1791
dp->two = two;
1792
- dp->score = 0;
1793
- dp->status = 0;
1794
- dp->source_stays = 0;
1795
- dp->broken_pair = 0;
1792
if (queue)
1793
diff_q(queue, dp);
1794
return dp;
diffcore-rename.c
+1
@@ -205,6 +205,7 @@ static void record_rename_pair(int dst_index, int src_index, int score)
205
fill_filespec(two, dst->sha1, dst->mode);
206
207
dp = diff_queue(NULL, one, two);
208
+ dp->renamed_pair = 1;
209
if (!strcmp(src->path, dst->path))
210
dp->score = rename_src[src_index].score;
211
else
diffcore.h
+2
-1
@@ -53,11 +53,12 @@ struct diff_filepair {
53
char status; /* M C R N D U (see Documentation/diff-format.txt) */
54
unsigned source_stays : 1; /* all of R/C are copies */
55
unsigned broken_pair : 1;
56
+ unsigned renamed_pair : 1;
57
};
58
#define DIFF_PAIR_UNMERGED(p) \
59
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
60
60
-#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
61
+#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
62
63
#define DIFF_PAIR_BROKEN(p) \
64
( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \