| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='combined diff show only paths that are different to all parents' |
| 4 | |
| 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | # verify that diffc.expect matches output of |
| 11 | # $(git diff -c --name-only HEAD HEAD^ HEAD^2) |
| 12 | diffc_verify () { |
| 13 | git diff -c --name-only HEAD HEAD^ HEAD^2 >diffc.actual && |
| 14 | test_cmp diffc.expect diffc.actual |
| 15 | } |
| 16 | |
| 17 | test_expect_success 'trivial merge - combine-diff empty' ' |
| 18 | for i in $(test_seq 1 9) |
| 19 | do |
| 20 | echo $i >$i.txt && |
| 21 | git add $i.txt || return 1 |
| 22 | done && |
| 23 | git commit -m "init" && |
| 24 | git checkout -b side && |
| 25 | for i in $(test_seq 2 9) |
| 26 | do |
| 27 | echo $i/2 >>$i.txt || return 1 |
| 28 | done && |
| 29 | git commit -a -m "side 2-9" && |
| 30 | git checkout main && |
| 31 | echo 1/2 >1.txt && |
| 32 | git commit -a -m "main 1" && |
| 33 | git merge side && |
| 34 | >diffc.expect && |
| 35 | diffc_verify |
| 36 | ' |
| 37 | |
| 38 | |
| 39 | test_expect_success 'only one truly conflicting path' ' |
| 40 | git checkout side && |
| 41 | for i in $(test_seq 2 9) |
| 42 | do |
| 43 | echo $i/3 >>$i.txt || return 1 |
| 44 | done && |
| 45 | echo "4side" >>4.txt && |
| 46 | git commit -a -m "side 2-9 +4" && |
| 47 | git checkout main && |
| 48 | for i in $(test_seq 1 9) |
| 49 | do |
| 50 | echo $i/3 >>$i.txt || return 1 |
| 51 | done && |
| 52 | echo "4main" >>4.txt && |
| 53 | git commit -a -m "main 1-9 +4" && |
| 54 | test_must_fail git merge side && |
| 55 | cat <<-\EOF >4.txt && |
| 56 | 4 |
| 57 | 4/2 |
| 58 | 4/3 |
| 59 | 4main |
| 60 | 4side |
| 61 | EOF |
| 62 | git add 4.txt && |
| 63 | git commit -m "merge side (2)" && |
| 64 | echo 4.txt >diffc.expect && |
| 65 | diffc_verify |
| 66 | ' |
| 67 | |
| 68 | test_expect_success 'merge introduces new file' ' |
| 69 | git checkout side && |
| 70 | for i in $(test_seq 5 9) |
| 71 | do |
| 72 | echo $i/4 >>$i.txt || return 1 |
| 73 | done && |
| 74 | git commit -a -m "side 5-9" && |
| 75 | git checkout main && |
| 76 | for i in $(test_seq 1 3) |
| 77 | do |
| 78 | echo $i/4 >>$i.txt || return 1 |
| 79 | done && |
| 80 | git commit -a -m "main 1-3 +4hello" && |
| 81 | git merge side && |
| 82 | echo "Hello World" >4hello.txt && |
| 83 | git add 4hello.txt && |
| 84 | git commit --amend && |
| 85 | echo 4hello.txt >diffc.expect && |
| 86 | diffc_verify |
| 87 | ' |
| 88 | |
| 89 | test_expect_success 'merge removed a file' ' |
| 90 | git checkout side && |
| 91 | for i in $(test_seq 5 9) |
| 92 | do |
| 93 | echo $i/5 >>$i.txt || return 1 |
| 94 | done && |
| 95 | git commit -a -m "side 5-9" && |
| 96 | git checkout main && |
| 97 | for i in $(test_seq 1 3) |
| 98 | do |
| 99 | echo $i/4 >>$i.txt || return 1 |
| 100 | done && |
| 101 | git commit -a -m "main 1-3" && |
| 102 | git merge side && |
| 103 | git rm 4.txt && |
| 104 | git commit --amend && |
| 105 | echo 4.txt >diffc.expect && |
| 106 | diffc_verify |
| 107 | ' |
| 108 | |
| 109 | test_done |