]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'ks/recursive-rename-add-identical'
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Sep 2010 19:39:12 +0000 (12:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Sep 2010 19:39:12 +0000 (12:39 -0700)
* ks/recursive-rename-add-identical:
  RE: [PATCH] Avoid rename/add conflict when contents are identical

merge-recursive.c
t/t3030-merge-recursive.sh

index 20e1779428ee553a940592c09bbabe9ca9800a39..c5746988196b8139ca3234f8b30d03af56d33324 100644 (file)
@@ -955,6 +955,12 @@ static int process_renames(struct merge_options *o,
                                                        ren1->pair->two : NULL,
                                                        branch1 == o->branch1 ?
                                                        NULL : ren1->pair->two, 1);
+                       } else if ((dst_other.mode == ren1->pair->two->mode) &&
+                                  sha_eq(dst_other.sha1, ren1->pair->two->sha1)) {
+                               /* Added file on the other side
+                                  identical to the file being
+                                  renamed: clean merge */
+                               update_file(o, 1, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
                        } else if (!sha_eq(dst_other.sha1, null_sha1)) {
                                const char *new_path;
                                clean_merge = 0;
index efe2900a372601848248de33188bda292185ba40..e66e550b2449e76435a0bf16c6a9889c0794f858 100755 (executable)
@@ -23,6 +23,8 @@ test_expect_success 'setup 1' '
        git branch df-3 &&
        git branch remove &&
        git branch submod &&
+       git branch copy &&
+       git branch rename &&
 
        echo hello >>a &&
        cp a d/e &&
@@ -248,6 +250,22 @@ test_expect_success 'setup 7' '
        git commit -m "make d/ a submodule"
 '
 
+test_expect_success 'setup 8' '
+       git checkout rename &&
+       git mv a e &&
+       git add e &&
+       test_tick &&
+       git commit -m "rename a->e"
+'
+
+test_expect_success 'setup 9' '
+       git checkout copy &&
+       cp a e &&
+       git add e &&
+       test_tick &&
+       git commit -m "copy a->e"
+'
+
 test_expect_success 'merge-recursive simple' '
 
        rm -fr [abcd] &&
@@ -580,4 +598,21 @@ test_expect_failure 'merge-recursive simple w/submodule result' '
        test_cmp expected actual
 '
 
+test_expect_success 'merge-recursive copy vs. rename' '
+       git checkout -f copy &&
+       git merge rename &&
+       ( git ls-tree -r HEAD && git ls-files -s ) >actual &&
+       (
+               echo "100644 blob $o0   b"
+               echo "100644 blob $o0   c"
+               echo "100644 blob $o0   d/e"
+               echo "100644 blob $o0   e"
+               echo "100644 $o0 0      b"
+               echo "100644 $o0 0      c"
+               echo "100644 $o0 0      d/e"
+               echo "100644 $o0 0      e"
+       ) >expected &&
+       test_cmp expected actual
+'
+
 test_done