Merge branch 'os/fetch-check-not-current-branch'
[git/debian.git] / t / t4046-diff-unmerged.sh
blob0ae0cd3a524da312d7f1cc7b1d4b0f6ed7b2b529
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 case "$path" in ooo) continue ;; esac &&
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 done
31 done
32 done >ls-files-s.expect &&
33 git update-index --index-info <ls-files-s.expect &&
34 git ls-files -s >ls-files-s.actual &&
35 test_cmp ls-files-s.expect ls-files-s.actual
38 test_expect_success 'diff-files -0' '
39 for path in $paths
41 >"$path" &&
42 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" || return 1
43 done >diff-files-0.expect &&
44 git diff-files -0 >diff-files-0.actual &&
45 test_cmp diff-files-0.expect diff-files-0.actual
48 test_expect_success 'diff-files -1' '
49 for path in $paths
51 >"$path" &&
52 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
53 case "$path" in
54 x??) echo ":100644 100644 $blob1 $ZERO_OID M $path"
55 esac || return 1
56 done >diff-files-1.expect &&
57 git diff-files -1 >diff-files-1.actual &&
58 test_cmp diff-files-1.expect diff-files-1.actual
61 test_expect_success 'diff-files -2' '
62 for path in $paths
64 >"$path" &&
65 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
66 case "$path" in
67 ?x?) echo ":100644 100644 $blob2 $ZERO_OID M $path"
68 esac || return 1
69 done >diff-files-2.expect &&
70 git diff-files -2 >diff-files-2.actual &&
71 test_cmp diff-files-2.expect diff-files-2.actual &&
72 git diff-files >diff-files-default-2.actual &&
73 test_cmp diff-files-2.expect diff-files-default-2.actual
76 test_expect_success 'diff-files -3' '
77 for path in $paths
79 >"$path" &&
80 echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
81 case "$path" in
82 ??x) echo ":100644 100644 $blob3 $ZERO_OID M $path"
83 esac || return 1
84 done >diff-files-3.expect &&
85 git diff-files -3 >diff-files-3.actual &&
86 test_cmp diff-files-3.expect diff-files-3.actual
89 test_done