mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
ec10b018e7
Using 'test_must_be_empty' is preferable to '! test -s', because it gives a helpful error message if the given file is unexpectedly not empty, while the latter remains completely silent. Furthermore, it also catches cases when the given file unexpectedly does not exist at all. This patch was basically created by: sed -i -e 's/! test -s/test_must_be_empty/' t[0-9]*.sh with the following notable exceptions: - The '! test -s' check in '.gitmodules ignore=dirty suppresses submodules with untracked content' in 't7508-status.sh' is left as-is, because it's bogus and, therefore, it's subject of a dedicated patch. - The '! test -s' checks in 't9131-git-svn-empty-symlink.sh' and 't9135-git-svn-moved-branch-empty-file.sh' are immediately preceeded by a 'test -f' to ensure that the files exist in the first place. 'test_must_be_empty' ensures that as well, so those 'test -f' commands are removed as well. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
92 lines
1.8 KiB
Bash
Executable file
92 lines
1.8 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='giving ignored paths to git add'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
mkdir sub dir dir/sub &&
|
|
echo sub >.gitignore &&
|
|
echo ign >>.gitignore &&
|
|
for p in . sub dir dir/sub
|
|
do
|
|
>"$p/ign" &&
|
|
>"$p/file" || exit 1
|
|
done
|
|
'
|
|
|
|
for i in file dir/file dir 'd*'
|
|
do
|
|
test_expect_success "no complaints for unignored $i" '
|
|
rm -f .git/index &&
|
|
git add "$i" &&
|
|
git ls-files "$i" >out &&
|
|
test -s out
|
|
'
|
|
done
|
|
|
|
for i in ign dir/ign dir/sub dir/sub/*ign sub/file sub sub/*
|
|
do
|
|
test_expect_success "complaints for ignored $i" '
|
|
rm -f .git/index &&
|
|
test_must_fail git add "$i" 2>err &&
|
|
git ls-files "$i" >out &&
|
|
test_must_be_empty out
|
|
'
|
|
|
|
test_expect_success "complaints for ignored $i output" '
|
|
test_i18ngrep -e "Use -f if" err
|
|
'
|
|
|
|
test_expect_success "complaints for ignored $i with unignored file" '
|
|
rm -f .git/index &&
|
|
test_must_fail git add "$i" file 2>err &&
|
|
git ls-files "$i" >out &&
|
|
test_must_be_empty out
|
|
'
|
|
test_expect_success "complaints for ignored $i with unignored file output" '
|
|
test_i18ngrep -e "Use -f if" err
|
|
'
|
|
done
|
|
|
|
for i in sub sub/*
|
|
do
|
|
test_expect_success "complaints for ignored $i in dir" '
|
|
rm -f .git/index &&
|
|
(
|
|
cd dir &&
|
|
test_must_fail git add "$i" 2>err &&
|
|
git ls-files "$i" >out &&
|
|
test_must_be_empty out
|
|
)
|
|
'
|
|
|
|
test_expect_success "complaints for ignored $i in dir output" '
|
|
(
|
|
cd dir &&
|
|
test_i18ngrep -e "Use -f if" err
|
|
)
|
|
'
|
|
done
|
|
|
|
for i in ign file
|
|
do
|
|
test_expect_success "complaints for ignored $i in sub" '
|
|
rm -f .git/index &&
|
|
(
|
|
cd sub &&
|
|
test_must_fail git add "$i" 2>err &&
|
|
git ls-files "$i" >out &&
|
|
test_must_be_empty out
|
|
)
|
|
'
|
|
|
|
test_expect_success "complaints for ignored $i in sub output" '
|
|
(
|
|
cd sub &&
|
|
test_i18ngrep -e "Use -f if" err
|
|
)
|
|
'
|
|
done
|
|
|
|
test_done
|