Skip to content

Commit 27a6625

Browse files
peffgitster
authored andcommitted
t3600: fix &&-chain breakage for setup commands
As with the earlier patch to fix "trivial" &&-chain breakage, these missing "&&" operators are not a serious problem (e.g., we do not expect "echo" to fail). Ironically, however, inserting them shows that some of the commands _do_ fail. Specifically, some of the tests start by making sure we are at a commit with the string "content" in the file "foo". However, running "git commit" may fail because the previous test left us in that state already, and there is nothing to commit. We could remove these commands entirely, but they serve to document the test's assumptions, as well as make it robust when an earlier test has failed. We could use test_might_fail to handle all cases, but that would miss an unrelated failure to make the commit. Instead, we can just pass the --allow-empty flag to git-commit, which means that it will not complain if our setup is a noop. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 53350a3 commit 27a6625

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

t/t3600-rm.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,37 @@ test_expect_success \
3838

3939
test_expect_success \
4040
'Test that git rm --cached foo succeeds if the index matches the file' \
41-
'echo content > foo
42-
git add foo
41+
'echo content >foo &&
42+
git add foo &&
4343
git rm --cached foo'
4444

4545
test_expect_success \
4646
'Test that git rm --cached foo succeeds if the index matches the file' \
47-
'echo content > foo
48-
git add foo
49-
git commit -m foo
50-
echo "other content" > foo
47+
'echo content >foo &&
48+
git add foo &&
49+
git commit -m foo &&
50+
echo "other content" >foo &&
5151
git rm --cached foo'
5252

5353
test_expect_success \
5454
'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' '
55-
echo content > foo
56-
git add foo
57-
git commit -m foo
58-
echo "other content" > foo
59-
git add foo
60-
echo "yet another content" > foo
55+
echo content >foo &&
56+
git add foo &&
57+
git commit -m foo --allow-empty &&
58+
echo "other content" >foo &&
59+
git add foo &&
60+
echo "yet another content" >foo &&
6161
test_must_fail git rm --cached foo
6262
'
6363

6464
test_expect_success \
6565
'Test that git rm --cached -f foo works in case where --cached only did not' \
66-
'echo content > foo
67-
git add foo
68-
git commit -m foo
69-
echo "other content" > foo
70-
git add foo
71-
echo "yet another content" > foo
66+
'echo content >foo &&
67+
git add foo &&
68+
git commit -m foo --allow-empty &&
69+
echo "other content" >foo &&
70+
git add foo &&
71+
echo "yet another content" >foo &&
7272
git rm --cached -f foo'
7373

7474
test_expect_success \

0 commit comments

Comments
 (0)