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