diff options
Diffstat (limited to 't/t3030-merge-recursive.sh')
-rwxr-xr-x | t/t3030-merge-recursive.sh | 245 |
1 files changed, 157 insertions, 88 deletions
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 607f57ff94..a5e3da7e41 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -22,6 +22,13 @@ test_expect_success 'setup 1' ' git branch df-2 && git branch df-3 && git branch remove && + git branch submod && + git branch copy && + git branch rename && + if test_have_prereq SYMLINKS + then + git branch rename-ln + fi && echo hello >>a && cp a d/e && @@ -43,7 +50,7 @@ test_expect_success 'setup 1' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' test_expect_success 'setup 2' ' @@ -61,7 +68,7 @@ test_expect_success 'setup 2' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual && + test_cmp expected actual && echo goodbye >>a && o2=$(git hash-object a) && @@ -82,7 +89,7 @@ test_expect_success 'setup 2' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' test_expect_success 'setup 3' ' @@ -100,7 +107,7 @@ test_expect_success 'setup 3' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual && + test_cmp expected actual && rm -f b && mkdir b && echo df-1 >b/c && git add b/c && o3=$(git hash-object b/c) && @@ -119,7 +126,7 @@ test_expect_success 'setup 3' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' test_expect_success 'setup 4' ' @@ -137,7 +144,7 @@ test_expect_success 'setup 4' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual && + test_cmp expected actual && rm -f a && mkdir a && echo df-2 >a/c && git add a/c && o4=$(git hash-object a/c) && @@ -156,7 +163,7 @@ test_expect_success 'setup 4' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' test_expect_success 'setup 5' ' @@ -174,7 +181,7 @@ test_expect_success 'setup 5' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual && + test_cmp expected actual && rm -f b && echo remove-conflict >a && @@ -195,7 +202,7 @@ test_expect_success 'setup 5' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -214,7 +221,7 @@ test_expect_success 'setup 6' ' echo "100644 $o0 0 c" echo "100644 $o0 0 d/e" ) >expected && - git diff -u expected actual && + test_cmp expected actual && rm -fr d && echo df-3 >d && git add d && o6=$(git hash-object d) && @@ -233,7 +240,44 @@ test_expect_success 'setup 6' ' echo "100644 $o0 0 c" echo "100644 $o6 0 d" ) >expected && - git diff -u expected actual + test_cmp expected actual +' + +test_expect_success 'setup 7' ' + + git checkout submod && + git rm d/e && + test_tick && + git commit -m "remove d/e" && + git update-index --add --cacheinfo 160000 $c1 d && + test_tick && + 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" && + if test_have_prereq SYMLINKS + then + git checkout rename-ln && + git mv a e && + ln -s e a && + git add a e && + test_tick && + git commit -m "rename a->e, symlink a->e" && + oln=`printf e | git hash-object --stdin` + fi +' + +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' ' @@ -241,17 +285,7 @@ test_expect_success 'merge-recursive simple' ' rm -fr [abcd] && git checkout -f "$c2" && - git-merge-recursive "$c0" -- "$c2" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1" ' test_expect_success 'merge-recursive result' ' @@ -265,26 +299,32 @@ test_expect_success 'merge-recursive result' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' +test_expect_success 'fail if the index has unresolved entries' ' + + rm -fr [abcd] && + git checkout -f "$c1" && + + test_must_fail git merge "$c5" && + test_must_fail git merge "$c5" 2> out && + test_i18ngrep "not possible because you have unmerged files" out && + git add -u && + test_must_fail git merge "$c5" 2> out && + test_i18ngrep "You have not concluded your merge" out && + rm -f .git/MERGE_HEAD && + test_must_fail git merge "$c5" 2> out && + test_i18ngrep "Your local changes to the following files would be overwritten by merge:" out +' + test_expect_success 'merge-recursive remove conflict' ' rm -fr [abcd] && git checkout -f "$c1" && - git-merge-recursive "$c0" -- "$c1" "$c5" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5" ' test_expect_success 'merge-recursive remove conflict' ' @@ -297,7 +337,7 @@ test_expect_success 'merge-recursive remove conflict' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -306,7 +346,7 @@ test_expect_success 'merge-recursive d/f simple' ' git reset --hard && git checkout -f "$c1" && - git-merge-recursive "$c0" -- "$c1" "$c3" + git merge-recursive "$c0" -- "$c1" "$c3" ' test_expect_success 'merge-recursive result' ' @@ -318,7 +358,7 @@ test_expect_success 'merge-recursive result' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -328,17 +368,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c1" && - git-merge-recursive "$c0" -- "$c1" "$c4" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -352,7 +382,7 @@ test_expect_success 'merge-recursive d/f conflict result' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -362,17 +392,7 @@ test_expect_success 'merge-recursive d/f conflict the other way' ' git reset --hard && git checkout -f "$c4" && - git-merge-recursive "$c0" -- "$c4" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1" ' test_expect_success 'merge-recursive d/f conflict result the other way' ' @@ -386,7 +406,7 @@ test_expect_success 'merge-recursive d/f conflict result the other way' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -396,17 +416,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c1" && - git-merge-recursive "$c0" -- "$c1" "$c6" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -420,7 +430,7 @@ test_expect_success 'merge-recursive d/f conflict result' ' echo "100644 $o0 1 d/e" echo "100644 $o1 2 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -430,17 +440,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c6" && - git-merge-recursive "$c0" -- "$c6" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -454,7 +454,7 @@ test_expect_success 'merge-recursive d/f conflict result' ' echo "100644 $o0 1 d/e" echo "100644 $o1 3 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual ' @@ -480,7 +480,7 @@ test_expect_success 'reset and bind merge' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual && + test_cmp expected actual && git read-tree --prefix=a1/ master && git ls-files -s >actual && @@ -498,7 +498,7 @@ test_expect_success 'reset and bind merge' ' echo "100644 $o0 0 c" echo "100644 $o1 0 d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual && git read-tree --prefix=z/ master && git ls-files -s >actual && @@ -520,8 +520,77 @@ test_expect_success 'reset and bind merge' ' echo "100644 $o0 0 z/c" echo "100644 $o1 0 z/d/e" ) >expected && - git diff -u expected actual + test_cmp expected actual + +' + +test_expect_success 'merge removes empty directories' ' + + git reset --hard master && + git checkout -b rm && + git rm d/e && + git commit -mremoved-d/e && + git checkout master && + git merge -s recursive rm && + test_must_fail test -d d +' + +test_expect_failure 'merge-recursive simple w/submodule' ' + + git checkout submod && + git merge remove +' + +test_expect_failure 'merge-recursive simple w/submodule result' ' + + git ls-files -s >actual && + ( + echo "100644 $o5 0 a" + echo "100644 $o0 0 c" + echo "160000 $c1 0 d" + ) >expected && + 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 ' +if test_have_prereq SYMLINKS +then + test_expect_failure 'merge-recursive rename vs. rename/symlink' ' + + git checkout -f rename && + git merge rename-ln && + ( git ls-tree -r HEAD ; git ls-files -s ) >actual && + ( + echo "120000 blob $oln a" + echo "100644 blob $o0 b" + echo "100644 blob $o0 c" + echo "100644 blob $o0 d/e" + echo "100644 blob $o0 e" + echo "120000 $oln 0 a" + 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 + ' +fi + + test_done |