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" &&
|
t4046: avoid continue in &&-chain for zsh
zsh has a bug in which the keyword "continue" within an &&-chain is not
effective and the code following it is executed nonetheless.
Fortunately, this bug has been fixed upstream in 12e5db145 ("51608:
Don't execute commands after "continue &&"", 2023-03-29). However, zsh
releases very infrequently, so it is not present in a stable release
yet.
That, combined with the fact that almost all zsh users get their shell
from their OS vendor, means that it will likely be a long time before
this problem is fixed for most users. We have other workarounds in
place for FreeBSD ash and dash, so it shouldn't be too difficult to add
one here, either.
Replace the existing code with a test and if-block, which comes only at
the cost of an additional indentation, and leaves the code a little more
idiomatic anyway.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-04-26 22:11:53 +00:00
|
|
|
if test "$path" != ooo
|
|
|
|
then
|
|
|
|
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 ||
|
|
|
|
return 1
|
|
|
|
fi
|
2015-03-25 05:29:52 +00:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2022-12-14 17:41:51 +00:00
|
|
|
test_expect_success 'diff --stat' '
|
|
|
|
for path in $paths
|
|
|
|
do
|
|
|
|
echo " $path | Unmerged" || return 1
|
|
|
|
done >diff-stat.expect &&
|
|
|
|
echo " 0 files changed" >>diff-stat.expect &&
|
|
|
|
git diff --cached --stat >diff-stat.actual &&
|
|
|
|
test_cmp diff-stat.expect diff-stat.actual
|
|
|
|
'
|
|
|
|
|
2024-05-05 10:19:56 +00:00
|
|
|
test_expect_success 'diff --quiet' '
|
|
|
|
test_expect_code 1 git diff --cached --quiet
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff --quiet --ignore-all-space' '
|
|
|
|
test_expect_code 1 git diff --cached --quiet --ignore-all-space
|
|
|
|
'
|
|
|
|
|
2011-04-22 23:19:27 +00:00
|
|
|
test_done
|