]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4046-diff-unmerged.sh
Merge branch 'jk/ci-macos-gcc13-fix'
[thirdparty/git.git] / t / t4046-diff-unmerged.sh
1 #!/bin/sh
2
3 test_description='diff with unmerged index entries'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success setup '
9 for i in 0 1 2 3
10 do
11 blob=$(echo $i | git hash-object --stdin) &&
12 eval "blob$i=$blob" &&
13 eval "m$i=\"100644 \$blob$i $i\"" || return 1
14 done &&
15 paths= &&
16 for b in o x
17 do
18 for o in o x
19 do
20 for t in o x
21 do
22 path="$b$o$t" &&
23 if test "$path" != ooo
24 then
25 paths="$paths$path " &&
26 p=" $path" &&
27 case "$b" in x) echo "$m1$p" ;; esac &&
28 case "$o" in x) echo "$m2$p" ;; esac &&
29 case "$t" in x) echo "$m3$p" ;; esac ||
30 return 1
31 fi
32 done
33 done
34 done >ls-files-s.expect &&
35 git update-index --index-info <ls-files-s.expect &&
36 git ls-files -s >ls-files-s.actual &&
37 test_cmp ls-files-s.expect ls-files-s.actual
38 '
39
40 test_expect_success 'diff-files -0' '
41 for path in $paths
42 do
43 >"$path" &&
44 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" || return 1
45 done >diff-files-0.expect &&
46 git diff-files -0 >diff-files-0.actual &&
47 test_cmp diff-files-0.expect diff-files-0.actual
48 '
49
50 test_expect_success 'diff-files -1' '
51 for path in $paths
52 do
53 >"$path" &&
54 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
55 case "$path" in
56 x??) echo ":100644 100644 $blob1 $ZERO_OID M $path"
57 esac || return 1
58 done >diff-files-1.expect &&
59 git diff-files -1 >diff-files-1.actual &&
60 test_cmp diff-files-1.expect diff-files-1.actual
61 '
62
63 test_expect_success 'diff-files -2' '
64 for path in $paths
65 do
66 >"$path" &&
67 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
68 case "$path" in
69 ?x?) echo ":100644 100644 $blob2 $ZERO_OID M $path"
70 esac || return 1
71 done >diff-files-2.expect &&
72 git diff-files -2 >diff-files-2.actual &&
73 test_cmp diff-files-2.expect diff-files-2.actual &&
74 git diff-files >diff-files-default-2.actual &&
75 test_cmp diff-files-2.expect diff-files-default-2.actual
76 '
77
78 test_expect_success 'diff-files -3' '
79 for path in $paths
80 do
81 >"$path" &&
82 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
83 case "$path" in
84 ??x) echo ":100644 100644 $blob3 $ZERO_OID M $path"
85 esac || return 1
86 done >diff-files-3.expect &&
87 git diff-files -3 >diff-files-3.actual &&
88 test_cmp diff-files-3.expect diff-files-3.actual
89 '
90
91 test_expect_success 'diff --stat' '
92 for path in $paths
93 do
94 echo " $path | Unmerged" || return 1
95 done >diff-stat.expect &&
96 echo " 0 files changed" >>diff-stat.expect &&
97 git diff --cached --stat >diff-stat.actual &&
98 test_cmp diff-stat.expect diff-stat.actual
99 '
100
101 test_done