aboutsummaryrefslogtreecommitdiff
path: root/t/t3700-add.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t3700-add.sh')
-rwxr-xr-xt/t3700-add.sh75
1 files changed, 57 insertions, 18 deletions
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index df580a5806..2947bf9a6b 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -38,7 +38,8 @@ test_expect_success 'Test with no pathspecs' '
'
test_expect_success 'Post-check that foo is in the index' '
- git ls-files foo | grep foo
+ git ls-files foo >actual &&
+ test_grep foo actual
'
test_expect_success 'Test that "git add -- -q" works' '
@@ -140,7 +141,7 @@ test_expect_success 'error out when attempting to add ignored ones but add other
git ls-files >files &&
sed -n "/\\.ig/p" <files >actual &&
test_must_be_empty actual &&
- grep a.if files
+ test_grep a.if files
'
test_expect_success 'add ignored ones with -f' '
@@ -195,8 +196,9 @@ test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries'
echo new > file &&
echo new > symlink &&
git add file symlink &&
- git ls-files --stage | grep "^100755 .* 0 file$" &&
- git ls-files --stage | grep "^120000 .* 0 symlink$"
+ git ls-files --stage >actual &&
+ test_grep "^100755 .* 0 file$" actual &&
+ test_grep "^120000 .* 0 symlink$" actual
'
test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' '
@@ -212,8 +214,9 @@ test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over st
echo new > file &&
echo new > symlink &&
git add file symlink &&
- git ls-files --stage | grep "^100755 .* 0 file$" &&
- git ls-files --stage | grep "^120000 .* 0 symlink$"
+ git ls-files --stage >actual &&
+ test_grep "^100755 .* 0 file$" actual &&
+ test_grep "^120000 .* 0 symlink$" actual
'
test_expect_success 'git add --refresh' '
@@ -238,8 +241,8 @@ test_expect_success 'git add --refresh with pathspec' '
test_must_be_empty actual &&
git diff-files --name-only >actual &&
- ! grep bar actual &&
- grep baz actual
+ test_grep ! bar actual &&
+ test_grep baz actual
'
test_expect_success 'git add --refresh correctly reports no match error' "
@@ -254,7 +257,8 @@ test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unr
date >foo2 &&
chmod 0 foo2 &&
test_must_fail git add --verbose . &&
- ! ( git ls-files foo1 | grep foo1 )
+ git ls-files foo1 >actual &&
+ test_grep ! foo1 actual
'
rm -f foo2
@@ -265,7 +269,8 @@ test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '
date >foo2 &&
chmod 0 foo2 &&
test_must_fail git add --verbose --ignore-errors . &&
- git ls-files foo1 | grep foo1
+ git ls-files foo1 >actual &&
+ test_grep foo1 actual
'
rm -f foo2
@@ -277,7 +282,8 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '
date >foo2 &&
chmod 0 foo2 &&
test_must_fail git add --verbose . &&
- git ls-files foo1 | grep foo1
+ git ls-files foo1 >actual &&
+ test_grep foo1 actual
'
rm -f foo2
@@ -288,7 +294,8 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '
date >foo2 &&
chmod 0 foo2 &&
test_must_fail git add --verbose . &&
- ! ( git ls-files foo1 | grep foo1 )
+ git ls-files foo1 >actual &&
+ test_grep ! foo1 actual
'
rm -f foo2
@@ -299,7 +306,8 @@ test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '
date >foo2 &&
chmod 0 foo2 &&
test_must_fail git add --verbose --no-ignore-errors . &&
- ! ( git ls-files foo1 | grep foo1 ) &&
+ git ls-files foo1 >actual &&
+ test_grep ! foo1 actual &&
git config add.ignore-errors 0
'
rm -f foo2
@@ -308,8 +316,10 @@ test_expect_success BSLASHPSPEC "git add 'fo\\[ou\\]bar' ignores foobar" '
git reset --hard &&
touch fo\[ou\]bar foobar &&
git add '\''fo\[ou\]bar'\'' &&
- git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar &&
- ! ( git ls-files foobar | grep foobar )
+ git ls-files fo\[ou\]bar >actual &&
+ test_grep -F fo\[ou\]bar actual &&
+ git ls-files foobar >actual &&
+ test_grep ! foobar actual
'
test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
@@ -326,7 +336,8 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
test_expect_success '"add non-existent" should fail' '
test_must_fail git add non-existent &&
- ! (git ls-files | grep "non-existent")
+ git ls-files >actual &&
+ test_grep ! "non-existent" actual
'
test_expect_success 'git add -A on empty repo does not error out' '
@@ -388,6 +399,7 @@ test_expect_success 'error on a repository with no commits' '
test_must_fail git add empty >actual 2>&1 &&
cat >expect <<-EOF &&
error: '"'empty/'"' does not have a commit checked out
+ error: unable to index file '"'empty/'"'
fatal: adding files failed
EOF
test_cmp expect actual
@@ -535,9 +547,36 @@ test_expect_success 'all statuses changed in folder if . is given' '
touch x y z sub/a sub/dir/b &&
git add -A &&
git add --chmod=+x . &&
- test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&
+ git ls-files --stage >actual &&
+ test_grep ! ^100644 actual &&
git add --chmod=-x . &&
- test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
+ git ls-files --stage >actual &&
+ test_grep ! ^100755 actual
+ )
+'
+
+test_expect_success 'cannot add a submodule of a different algorithm' '
+ git init --object-format=sha256 sha256 &&
+ (
+ cd sha256 &&
+ test_commit abc &&
+ git init --object-format=sha1 submodule &&
+ test_commit -C submodule def &&
+ test_must_fail git add submodule 2>err &&
+ test_grep "cannot add a submodule of a different hash algorithm" err &&
+ git ls-files --stage >entries &&
+ test_grep ! ^160000 entries
+ ) &&
+ git init --object-format=sha1 sha1 &&
+ (
+ cd sha1 &&
+ test_commit abc &&
+ git init --object-format=sha256 submodule &&
+ test_commit -C submodule def &&
+ test_must_fail git add submodule 2>err &&
+ test_grep "cannot add a submodule of a different hash algorithm" err &&
+ git ls-files --stage >entries &&
+ test_grep ! ^160000 entries
)
'