Skip to content

Commit

Permalink
diff.c: do not use pathname comparison to tell renames
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Aug 3, 2006
1 parent c43ce6d commit ef67768
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 1 addition & 5 deletions diff.c
Expand Up @@ -1786,13 +1786,9 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
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;
Expand Down
1 change: 1 addition & 0 deletions diffcore-rename.c
Expand Up @@ -205,6 +205,7 @@ static void record_rename_pair(int dst_index, int src_index, int score)
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
Expand Down
3 changes: 2 additions & 1 deletion diffcore.h
Expand Up @@ -53,11 +53,12 @@ struct diff_filepair {
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)) && \
Expand Down

0 comments on commit ef67768

Please sign in to comment.