Merge branch 'es/worktree-repair-copied' into cw/worktrees-relative
[git/gitster.git] / t / t4046-diff-unmerged.sh
blobafda629c98137f236371dc100410996632f7a52b
1 #!/bin/sh
3 test_description='diff with unmerged index entries'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success setup '
9 for i in 0 1 2 3
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
18 for o in o x
20 for t in o x
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
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
40 test_expect_success 'diff-files -0' '
41 for path in $paths
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
50 test_expect_success 'diff-files -1' '
51 for path in $paths
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
63 test_expect_success 'diff-files -2' '
64 for path in $paths
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
78 test_expect_success 'diff-files -3' '
79 for path in $paths
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
91 test_expect_success 'diff --stat' '
92 for path in $paths
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
101 test_expect_success 'diff --quiet' '
102 test_expect_code 1 git diff --cached --quiet
105 test_expect_success 'diff --quiet --ignore-all-space' '
106 test_expect_code 1 git diff --cached --quiet --ignore-all-space
109 test_done