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>

Jeff King committed Mar 20, 2015 at 06:12 UTC 27a6625b13d7475d28f425adb2b7be221cf3c8e0
1 file changed +18 -18
t/t3600-rm.sh
+18 -18
@@ -38,37 +38,37 @@ test_expect_success \
38
39 test_expect_success \
40 '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 &&
43 git rm --cached foo'
44
45 test_expect_success \
46 '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 &&
51 git rm --cached foo'
52
53 test_expect_success \
54 '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 &&
61 test_must_fail git rm --cached foo
62 '
63
64 test_expect_success \
65 '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 &&
72 git rm --cached -f foo'
73
74 test_expect_success \