2008-03-31 00:28:05 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='more git add -u'
|
|
|
|
|
2021-10-30 22:24:20 +00:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2008-03-31 00:28:05 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
>xyzzy &&
|
|
|
|
_empty=$(git hash-object --stdin <xyzzy) &&
|
|
|
|
>yomin &&
|
|
|
|
>caskly &&
|
2009-03-04 21:38:24 +00:00
|
|
|
if test_have_prereq SYMLINKS; then
|
|
|
|
ln -s frotz nitfol &&
|
|
|
|
T_letter=T
|
|
|
|
else
|
|
|
|
printf %s frotz > nitfol &&
|
|
|
|
T_letter=M
|
|
|
|
fi &&
|
2008-03-31 00:28:05 +00:00
|
|
|
mkdir rezrov &&
|
|
|
|
>rezrov/bozbar &&
|
|
|
|
git add caskly xyzzy yomin nitfol rezrov/bozbar &&
|
|
|
|
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success modify '
|
|
|
|
rm -f xyzzy yomin nitfol caskly &&
|
|
|
|
# caskly disappears (not a submodule)
|
|
|
|
mkdir caskly &&
|
|
|
|
# nitfol changes from symlink to regular
|
|
|
|
>nitfol &&
|
|
|
|
# rezrov/bozbar disappears
|
|
|
|
rm -fr rezrov &&
|
2009-03-04 21:38:24 +00:00
|
|
|
if test_have_prereq SYMLINKS; then
|
|
|
|
ln -s xyzzy rezrov
|
|
|
|
else
|
|
|
|
printf %s xyzzy > rezrov
|
|
|
|
fi &&
|
2008-03-31 00:28:05 +00:00
|
|
|
# xyzzy disappears (not a submodule)
|
|
|
|
mkdir xyzzy &&
|
|
|
|
echo gnusto >xyzzy/bozbar &&
|
|
|
|
# yomin gets replaced with a submodule
|
|
|
|
mkdir yomin &&
|
|
|
|
>yomin/yomin &&
|
|
|
|
(
|
|
|
|
cd yomin &&
|
|
|
|
git init &&
|
|
|
|
git add yomin &&
|
|
|
|
git commit -m "sub initial"
|
|
|
|
) &&
|
|
|
|
yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) &&
|
|
|
|
# yonk is added and then turned into a submodule
|
|
|
|
# this should appear as T in diff-files and as A in diff-index
|
|
|
|
>yonk &&
|
|
|
|
git add yonk &&
|
|
|
|
rm -f yonk &&
|
|
|
|
mkdir yonk &&
|
|
|
|
>yonk/yonk &&
|
|
|
|
(
|
|
|
|
cd yonk &&
|
|
|
|
git init &&
|
|
|
|
git add yonk &&
|
|
|
|
git commit -m "sub initial"
|
|
|
|
) &&
|
|
|
|
yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) &&
|
|
|
|
# zifmia is added and then removed
|
|
|
|
# this should appear in diff-files but not in diff-index.
|
|
|
|
>zifmia &&
|
|
|
|
git add zifmia &&
|
|
|
|
rm -f zifmia &&
|
|
|
|
mkdir zifmia &&
|
|
|
|
{
|
|
|
|
git ls-tree -r HEAD |
|
|
|
|
sed -e "s/^/:/" -e "
|
|
|
|
/ caskly/{
|
2018-05-13 02:24:13 +00:00
|
|
|
s/ caskly/ $ZERO_OID D&/
|
2008-03-31 00:28:05 +00:00
|
|
|
s/blob/000000/
|
|
|
|
}
|
|
|
|
/ nitfol/{
|
2018-05-13 02:24:13 +00:00
|
|
|
s/ nitfol/ $ZERO_OID $T_letter&/
|
2008-03-31 00:28:05 +00:00
|
|
|
s/blob/100644/
|
|
|
|
}
|
|
|
|
/ rezrov.bozbar/{
|
2018-05-13 02:24:13 +00:00
|
|
|
s/ rezrov.bozbar/ $ZERO_OID D&/
|
2008-03-31 00:28:05 +00:00
|
|
|
s/blob/000000/
|
|
|
|
}
|
|
|
|
/ xyzzy/{
|
2018-05-13 02:24:13 +00:00
|
|
|
s/ xyzzy/ $ZERO_OID D&/
|
2008-03-31 00:28:05 +00:00
|
|
|
s/blob/000000/
|
|
|
|
}
|
|
|
|
/ yomin/{
|
2018-05-13 02:24:13 +00:00
|
|
|
s/ yomin/ $ZERO_OID T&/
|
2008-03-31 00:28:05 +00:00
|
|
|
s/blob/160000/
|
|
|
|
}
|
|
|
|
"
|
|
|
|
} >expect &&
|
|
|
|
{
|
tests: fix broken &&-chains in `{...}` groups
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 `{...}` groups 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:08 +00:00
|
|
|
cat expect &&
|
|
|
|
echo ":100644 160000 $_empty $ZERO_OID T yonk" &&
|
2018-05-13 02:24:13 +00:00
|
|
|
echo ":100644 000000 $_empty $ZERO_OID D zifmia"
|
2008-03-31 00:28:05 +00:00
|
|
|
} >expect-files &&
|
|
|
|
{
|
tests: fix broken &&-chains in `{...}` groups
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 `{...}` groups 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:08 +00:00
|
|
|
cat expect &&
|
2018-05-13 02:24:13 +00:00
|
|
|
echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
|
2008-03-31 00:28:05 +00:00
|
|
|
} >expect-index &&
|
|
|
|
{
|
tests: fix broken &&-chains in `{...}` groups
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 `{...}` groups 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:08 +00:00
|
|
|
echo "100644 $_empty 0 nitfol" &&
|
|
|
|
echo "160000 $yomin 0 yomin" &&
|
2008-03-31 00:28:05 +00:00
|
|
|
echo "160000 $yonk 0 yonk"
|
|
|
|
} >expect-final
|
|
|
|
'
|
|
|
|
|
2008-03-31 00:30:08 +00:00
|
|
|
test_expect_success diff-files '
|
2008-03-31 00:28:05 +00:00
|
|
|
git diff-files --raw >actual &&
|
2008-07-22 21:17:43 +00:00
|
|
|
test_cmp expect-files actual
|
2008-03-31 00:28:05 +00:00
|
|
|
'
|
|
|
|
|
2008-03-31 00:29:48 +00:00
|
|
|
test_expect_success diff-index '
|
2008-03-31 00:28:05 +00:00
|
|
|
git diff-index --raw HEAD -- >actual &&
|
2008-07-22 21:17:43 +00:00
|
|
|
test_cmp expect-index actual
|
2008-03-31 00:28:05 +00:00
|
|
|
'
|
|
|
|
|
2008-03-31 00:30:08 +00:00
|
|
|
test_expect_success 'add -u' '
|
2008-03-31 00:28:05 +00:00
|
|
|
rm -f ".git/saved-index" &&
|
|
|
|
cp -p ".git/index" ".git/saved-index" &&
|
|
|
|
git add -u &&
|
|
|
|
git ls-files -s >actual &&
|
2008-07-22 21:17:43 +00:00
|
|
|
test_cmp expect-final actual
|
2008-03-31 00:28:05 +00:00
|
|
|
'
|
|
|
|
|
2008-03-31 00:30:08 +00:00
|
|
|
test_expect_success 'commit -a' '
|
2008-03-31 00:28:05 +00:00
|
|
|
if test -f ".git/saved-index"
|
|
|
|
then
|
|
|
|
rm -f ".git/index" &&
|
|
|
|
mv ".git/saved-index" ".git/index"
|
|
|
|
fi &&
|
|
|
|
git commit -m "second" -a &&
|
|
|
|
git ls-files -s >actual &&
|
2008-07-22 21:17:43 +00:00
|
|
|
test_cmp expect-final actual &&
|
2008-03-31 00:28:05 +00:00
|
|
|
rm -f .git/index &&
|
|
|
|
git read-tree HEAD &&
|
|
|
|
git ls-files -s >actual &&
|
2008-07-22 21:17:43 +00:00
|
|
|
test_cmp expect-final actual
|
2008-03-31 00:28:05 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|