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