]>
Commit | Line | Data |
---|---|---|
095ce953 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='diff with unmerged index entries' | |
16d4bd4f ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
095ce953 JH |
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" && | |
e6821d09 | 13 | eval "m$i=\"100644 \$blob$i $i\"" || return 1 |
095ce953 JH |
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" && | |
058b8dc2 | 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 | |
e6821d09 JK |
32 | done |
33 | done | |
095ce953 JH |
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" && | |
cbe1d9d6 | 44 | echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" || return 1 |
095ce953 JH |
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" && | |
8125a58b | 54 | echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" && |
095ce953 | 55 | case "$path" in |
8125a58b | 56 | x??) echo ":100644 100644 $blob1 $ZERO_OID M $path" |
cbe1d9d6 | 57 | esac || return 1 |
095ce953 JH |
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" && | |
8125a58b | 67 | echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" && |
095ce953 | 68 | case "$path" in |
8125a58b | 69 | ?x?) echo ":100644 100644 $blob2 $ZERO_OID M $path" |
cbe1d9d6 | 70 | esac || return 1 |
095ce953 JH |
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" && | |
8125a58b | 82 | echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" && |
095ce953 | 83 | case "$path" in |
8125a58b | 84 | ??x) echo ":100644 100644 $blob3 $ZERO_OID M $path" |
cbe1d9d6 | 85 | esac || return 1 |
095ce953 JH |
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 | ||
209d9cb0 PG |
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 | ||
095ce953 | 101 | test_done |