]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'mz/maint-rename-unmerged' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 May 2011 17:41:24 +0000 (10:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 May 2011 17:41:24 +0000 (10:41 -0700)
* mz/maint-rename-unmerged:
  diffcore-rename: don't consider unmerged path as source

diffcore-rename.c
t/t7060-wtstatus.sh

index d40e40a3ac9c919475d6157464fa906e37b0dd80..0b9e99a04ee62d0d14900888f5b8b9ab3d957b5f 100644 (file)
@@ -466,7 +466,7 @@ void diffcore_rename(struct diff_options *options)
                        else
                                locate_rename_dst(p->two, 1);
                }
-               else if (!DIFF_FILE_VALID(p->two)) {
+               else if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {
                        /*
                         * If the source is a broken "delete", and
                         * they did not really want to get broken,
@@ -586,7 +586,10 @@ void diffcore_rename(struct diff_options *options)
                struct diff_filepair *p = q->queue[i];
                struct diff_filepair *pair_to_free = NULL;
 
-               if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
+               if (DIFF_PAIR_UNMERGED(p)) {
+                       diff_q(&outq, p);
+               }
+               else if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
                        /*
                         * Creation
                         *
index b4fcc86a10f15178da25da159e160b38d717f318..3a5d927f83730f53a67cfec76a0625008dfb71f2 100755 (executable)
@@ -56,4 +56,66 @@ test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' '
        )
 '
 
+test_expect_success 'rename & unmerged setup' '
+       git rm -f -r . &&
+       cat "$TEST_DIRECTORY/README" >ONE &&
+       git add ONE &&
+       test_tick &&
+       git commit -m "One commit with ONE" &&
+
+       echo Modified >TWO &&
+       cat ONE >>TWO &&
+       cat ONE >>THREE &&
+       git add TWO THREE &&
+       sha1=$(git rev-parse :ONE) &&
+       git rm --cached ONE &&
+       (
+               echo "100644 $sha1 1    ONE" &&
+               echo "100644 $sha1 2    ONE" &&
+               echo "100644 $sha1 3    ONE"
+       ) | git update-index --index-info &&
+       echo Further >>THREE
+'
+
+test_expect_success 'rename & unmerged status' '
+       git status -suno >actual &&
+       cat >expect <<-EOF &&
+       UU ONE
+       AM THREE
+       A  TWO
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' '
+       cat >expected <<-EOF &&
+       U       ONE
+       A       THREE
+       A       TWO
+       EOF
+       git diff-index --cached --name-status HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' '
+       cat >expected <<-EOF &&
+       U       ONE
+       A       THREE
+       A       TWO
+       EOF
+       git diff-index --cached --name-status HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
+       cat >expected <<-EOF &&
+       U       ONE
+       C       ONE     THREE
+       C       ONE     TWO
+       EOF
+       git diff-index --cached -C --name-status HEAD |
+       sed "s/^C[0-9]*/C/g" >actual &&
+       test_cmp expected actual
+'
+
 test_done