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 --- t/t4008-diff-break-rewrite.sh | 4 ++-- t/t4023-diff-rename-typechange.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh index 27e98a8f9d..8920464896 100755 --- a/t/t4008-diff-break-rewrite.sh +++ b/t/t4008-diff-break-rewrite.sh @@ -123,10 +123,10 @@ test_expect_success \ 'git diff-index -B -M "$tree" >current' # file0 changed from regular to symlink. file1 is very close to the preimage of file0. -# because we break file0, file1 can become a rename of it. +# the change does not make file0 disappear, so file1 is denoted as a copy of file0 cat >expected <<\EOF :100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0 -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 R file0 file1 +:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 C file0 file1 EOF test_expect_success \ diff --git a/t/t4023-diff-rename-typechange.sh b/t/t4023-diff-rename-typechange.sh index 55d549fcf4..8c9823765e 100755 --- a/t/t4023-diff-rename-typechange.sh +++ b/t/t4023-diff-rename-typechange.sh @@ -76,7 +76,8 @@ test_expect_success 'moves and renames' ' git diff-tree three four -r --name-status -B -M | sort >actual && { - echo "R100 foo bar" + # see -B -M (#6) in t4008 + echo "C100 foo bar" echo "T100 foo" } | sort >expect && test_cmp expect actual -- cgit v1.2.3