Merge branch 'ab/retire-refs-unused-funcs'
[git/debian.git] / t / t4057-diff-combined-paths.sh
blob7e5b74f72ee975ef87c8d5e539bc287268e18493
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-lib.sh
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
17 test_expect_success 'trivial merge - combine-diff empty' '
18 for i in $(test_seq 1 9)
20 echo $i >$i.txt &&
21 git add $i.txt
22 done &&
23 git commit -m "init" &&
24 git checkout -b side &&
25 for i in $(test_seq 2 9)
27 echo $i/2 >>$i.txt
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
39 test_expect_success 'only one truly conflicting path' '
40 git checkout side &&
41 for i in $(test_seq 2 9)
43 echo $i/3 >>$i.txt
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)
50 echo $i/3 >>$i.txt
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 &&
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
68 test_expect_success 'merge introduces new file' '
69 git checkout side &&
70 for i in $(test_seq 5 9)
72 echo $i/4 >>$i.txt
73 done &&
74 git commit -a -m "side 5-9" &&
75 git checkout main &&
76 for i in $(test_seq 1 3)
78 echo $i/4 >>$i.txt
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
89 test_expect_success 'merge removed a file' '
90 git checkout side &&
91 for i in $(test_seq 5 9)
93 echo $i/5 >>$i.txt
94 done &&
95 git commit -a -m "side 5-9" &&
96 git checkout main &&
97 for i in $(test_seq 1 3)
99 echo $i/4 >>$i.txt
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
109 test_done