From 6936b5859c47b826437218fbfc0e2bc0935f7136 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 23 Oct 2014 10:02:02 -0700 Subject: diff -B -M: fix output for "copy and then rewrite" case Starting from a single file, A, if you create B as a copy of A (and possibly make some edit) and then make extensive change to A, you will see: $ git diff -C --name-status C89 A B M A which is expected. However, if you ask the same question in a different way, you see this: $ git diff -B -M --name-status R89 A B M100 A telling us that A was rename-edited into B (as if "A will no longer exist as the result") and at the same time A itself was extensively edited. In this case, because the resulting tree still does have file A (even if it has contents vastly different from the original), we should use "C"opy, not "R"ename, to avoid hinting that A somehow goes away. Two existing tests were depending on the wrong behaviour, and fixed. Signed-off-by: Junio C Hamano --- diffcore-break.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'diffcore-break.c') diff --git a/diffcore-break.c b/diffcore-break.c index 1d9e530a8..5473493e1 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -246,6 +246,13 @@ static void merge_broken(struct diff_filepair *p, dp = diff_queue(outq, d->one, c->two); dp->score = p->score; + /* + * We will be one extra user of the same src side of the + * broken pair, if it was used as the rename source for other + * paths elsewhere. Increment to mark that the path stays + * in the resulting tree. + */ + d->one->rename_used++; diff_free_filespec_data(d->two); diff_free_filespec_data(c->one); free(d); -- cgit v1.2.1