Merge branch 'jc/diff-b-m'
authorJunio C Hamano <gitster@pobox.com>
Wed, 7 Jan 2015 20:44:41 +0000 (12:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Jan 2015 20:44:42 +0000 (12:44 -0800)
Fix long-standing bug in "diff -B -M" output.

* jc/diff-b-m:
diff -B -M: fix output for "copy and then rewrite" case

diffcore-break.c
t/t4008-diff-break-rewrite.sh
t/t4023-diff-rename-typechange.sh
index 1d9e530a84758e34d616690684c4842cd1af4cfc..5473493e10551633659d0727626ffc2273ef4f73 100644 (file)
@@ -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);
index 27e98a8f9d6c858468904542c500236b9e9f99c2..89204648965b2b6b7d7984e3398b3ef21a8d7c7e 100755 (executable)
@@ -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 \
index 55d549fcf441be927bc43b2c41107a90aa614c2a..8c9823765e66aca886a1ec32a8ad523c1c28e1bc 100755 (executable)
@@ -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