2011-04-22 23:19:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='diff with unmerged index entries'
|
2021-10-30 22:24:19 +00:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2011-04-22 23:19:27 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
for i in 0 1 2 3
|
|
|
|
do
|
|
|
|
blob=$(echo $i | git hash-object --stdin) &&
|
|
|
|
eval "blob$i=$blob" &&
|
2015-03-25 05:29:52 +00:00
|
|
|
eval "m$i=\"100644 \$blob$i $i\"" || return 1
|
2011-04-22 23:19:27 +00:00
|
|
|
done &&
|
|
|
|
paths= &&
|
|
|
|
for b in o x
|
|
|
|
do
|
|
|
|
for o in o x
|
|
|
|
do
|
|
|
|
for t in o x
|
|
|
|
do
|
|
|
|
path="$b$o$t" &&
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 05:11:06 +00:00
|
|
|
case "$path" in ooo) continue ;; esac &&
|
2011-04-22 23:19:27 +00:00
|
|
|
paths="$paths$path " &&
|
|
|
|
p=" $path" &&
|
|
|
|
case "$b" in x) echo "$m1$p" ;; esac &&
|
|
|
|
case "$o" in x) echo "$m2$p" ;; esac &&
|
|
|
|
case "$t" in x) echo "$m3$p" ;; esac ||
|
2015-03-25 05:29:52 +00:00
|
|
|
return 1
|
|
|
|
done
|
|
|
|
done
|
2011-04-22 23:19:27 +00:00
|
|
|
done >ls-files-s.expect &&
|
|
|
|
git update-index --index-info <ls-files-s.expect &&
|
|
|
|
git ls-files -s >ls-files-s.actual &&
|
|
|
|
test_cmp ls-files-s.expect ls-files-s.actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-files -0' '
|
|
|
|
for path in $paths
|
|
|
|
do
|
|
|
|
>"$path" &&
|
2021-12-09 05:11:13 +00:00
|
|
|
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" || return 1
|
2011-04-22 23:19:27 +00:00
|
|
|
done >diff-files-0.expect &&
|
|
|
|
git diff-files -0 >diff-files-0.actual &&
|
|
|
|
test_cmp diff-files-0.expect diff-files-0.actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-files -1' '
|
|
|
|
for path in $paths
|
|
|
|
do
|
|
|
|
>"$path" &&
|
2018-05-13 02:24:13 +00:00
|
|
|
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
|
2011-04-22 23:19:27 +00:00
|
|
|
case "$path" in
|
2018-05-13 02:24:13 +00:00
|
|
|
x??) echo ":100644 100644 $blob1 $ZERO_OID M $path"
|
2021-12-09 05:11:13 +00:00
|
|
|
esac || return 1
|
2011-04-22 23:19:27 +00:00
|
|
|
done >diff-files-1.expect &&
|
|
|
|
git diff-files -1 >diff-files-1.actual &&
|
|
|
|
test_cmp diff-files-1.expect diff-files-1.actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-files -2' '
|
|
|
|
for path in $paths
|
|
|
|
do
|
|
|
|
>"$path" &&
|
2018-05-13 02:24:13 +00:00
|
|
|
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
|
2011-04-22 23:19:27 +00:00
|
|
|
case "$path" in
|
2018-05-13 02:24:13 +00:00
|
|
|
?x?) echo ":100644 100644 $blob2 $ZERO_OID M $path"
|
2021-12-09 05:11:13 +00:00
|
|
|
esac || return 1
|
2011-04-22 23:19:27 +00:00
|
|
|
done >diff-files-2.expect &&
|
|
|
|
git diff-files -2 >diff-files-2.actual &&
|
|
|
|
test_cmp diff-files-2.expect diff-files-2.actual &&
|
|
|
|
git diff-files >diff-files-default-2.actual &&
|
|
|
|
test_cmp diff-files-2.expect diff-files-default-2.actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-files -3' '
|
|
|
|
for path in $paths
|
|
|
|
do
|
|
|
|
>"$path" &&
|
2018-05-13 02:24:13 +00:00
|
|
|
echo ":000000 100644 $ZERO_OID $ZERO_OID U $path" &&
|
2011-04-22 23:19:27 +00:00
|
|
|
case "$path" in
|
2018-05-13 02:24:13 +00:00
|
|
|
??x) echo ":100644 100644 $blob3 $ZERO_OID M $path"
|
2021-12-09 05:11:13 +00:00
|
|
|
esac || return 1
|
2011-04-22 23:19:27 +00:00
|
|
|
done >diff-files-3.expect &&
|
|
|
|
git diff-files -3 >diff-files-3.actual &&
|
|
|
|
test_cmp diff-files-3.expect diff-files-3.actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|