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