t: fix some trivial cases of ignored exit codes in loops
These are all cases where we do a setup step of the form: for i in $foo; do set_up $i || break done && more_setup would not notice a failure in set_up (because break always returns a 0 exit code). These are just setup steps that we do not expect to fail, but it does not hurt to be defensive. Most can be fixed by converting the "break" to a "return 1" (since we eval our tests inside a function for just this purpose). A few of the loops are inside subshells, so we can use just "exit 1" to break out of the subshell. And a few can actually be made shorter by just unrolling the loop. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 25, 2015 at 01:29 UTC
e6821d09e4655af94f9c8af07333ae710094996a
10 files changed
+24
-28
t/t3010-ls-files-killed-modified.sh
+4
-7
@@ -55,13 +55,10 @@ test_expect_success 'git update-index --add to add various paths.' '
55
: >path9 &&
56
date >path10 &&
57
git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 &&
58
- for i in 1 2
59
- do
60
- git init submod$i &&
61
- (
62
- cd submod$i && git commit --allow-empty -m "empty $i"
63
- ) || break
64
- done &&
58
+ git init submod1 &&
59
+ git -C submod1 commit --allow-empty -m "empty 1" &&
60
+ git init submod2 &&
61
+ git -C submod2 commit --allow-empty -m "empty 2" &&
62
git update-index --add submod[12] &&
63
(
64
cd submod1 &&
t/t3031-merge-criscross.sh
+1
-1
@@ -32,7 +32,7 @@ test_expect_success 'setup repo with criss-cross history' '
32
do
33
echo $n > data/$n &&
34
n=$(($n+1)) ||
35
- break
35
+ return 1
36
done &&
37
38
# check them in
t/t3202-show-branch-octopus.sh
+1
-1
@@ -19,7 +19,7 @@ test_expect_success 'setup' '
19
> file$i &&
20
git add file$i &&
21
test_tick &&
22
- git commit -m branch$i || break
22
+ git commit -m branch$i || return 1
23
done
24
25
'
t/t4024-diff-optimize-common.sh
+1
-1
@@ -139,7 +139,7 @@ test_expect_success setup '
139
( printf C; zs $n ) >file-c$n &&
140
( echo D; zs $n ) >file-d$n &&
141
142
- expect_pattern $n || break
142
+ expect_pattern $n || return 1
143
144
done >expect
145
'
t/t4046-diff-unmerged.sh
+4
-4
@@ -8,7 +8,7 @@ test_expect_success setup '
8
do
9
blob=$(echo $i | git hash-object --stdin) &&
10
eval "blob$i=$blob" &&
11
- eval "m$i=\"100644 \$blob$i $i\"" || break
11
+ eval "m$i=\"100644 \$blob$i $i\"" || return 1
12
done &&
13
paths= &&
14
for b in o x
@@ -24,9 +24,9 @@ test_expect_success setup '
24
case "$b" in x) echo "$m1$p" ;; esac &&
25
case "$o" in x) echo "$m2$p" ;; esac &&
26
case "$t" in x) echo "$m3$p" ;; esac ||
27
- break
28
- done || break
29
- done || break
27
+ return 1
28
+ done
29
+ done
30
done >ls-files-s.expect &&
31
git update-index --index-info <ls-files-s.expect &&
32
git ls-files -s >ls-files-s.actual &&
t/t4151-am-abort.sh
+1
-1
@@ -20,7 +20,7 @@ test_expect_success setup '
20
echo $i >otherfile-$i &&
21
git add otherfile-$i &&
22
test_tick &&
23
- git commit -a -m $i || break
23
+ git commit -a -m $i || return 1
24
done &&
25
git format-patch --no-numbered initial &&
26
git checkout -b side initial &&
t/t5505-remote.sh
+4
-4
@@ -579,7 +579,7 @@ test_expect_success 'update with arguments' '
579
cd one &&
580
for b in $(git branch -r)
581
do
582
- git branch -r -d $b || break
582
+ git branch -r -d $b || exit 1
583
done &&
584
git remote add manduca ../mirror &&
585
git remote add megaloprepus ../mirror &&
@@ -622,7 +622,7 @@ test_expect_success 'update default' '
622
cd one &&
623
for b in $(git branch -r)
624
do
625
- git branch -r -d $b || break
625
+ git branch -r -d $b || exit 1
626
done &&
627
git config remote.drosophila.skipDefaultUpdate true &&
628
git remote update default &&
@@ -642,7 +642,7 @@ test_expect_success 'update default (overridden, with funny whitespace)' '
642
cd one &&
643
for b in $(git branch -r)
644
do
645
- git branch -r -d $b || break
645
+ git branch -r -d $b || exit 1
646
done &&
647
git config remotes.default "$(printf "\t drosophila \n")" &&
648
git remote update default &&
@@ -656,7 +656,7 @@ test_expect_success 'update (with remotes.default defined)' '
656
cd one &&
657
for b in $(git branch -r)
658
do
659
- git branch -r -d $b || break
659
+ git branch -r -d $b || exit 1
660
done &&
661
git config remotes.default "drosophila" &&
662
git remote update &&
t/t5514-fetch-multiple.sh
+2
-2
@@ -120,7 +120,7 @@ test_expect_success 'git fetch --all (skipFetchAll)' '
120
(cd test4 &&
121
for b in $(git branch -r)
122
do
123
- git branch -r -d $b || break
123
+ git branch -r -d $b || exit 1
124
done &&
125
git remote add three ../three &&
126
git config remote.three.skipFetchAll true &&
@@ -144,7 +144,7 @@ test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
144
(cd test4 &&
145
for b in $(git branch -r)
146
do
147
- git branch -r -d $b || break
147
+ git branch -r -d $b || exit 1
148
done &&
149
git fetch --multiple one two three &&
150
git branch -r > output &&
t/t6026-merge-attr.sh
+3
-3
@@ -11,7 +11,7 @@ test_expect_success setup '
11
12
for f in text binary union
13
do
14
- echo Initial >$f && git add $f || break
14
+ echo Initial >$f && git add $f || return 1
15
done &&
16
test_tick &&
17
git commit -m Initial &&
@@ -19,7 +19,7 @@ test_expect_success setup '
19
git branch side &&
20
for f in text binary union
21
do
22
- echo Master >>$f && git add $f || break
22
+ echo Master >>$f && git add $f || return 1
23
done &&
24
test_tick &&
25
git commit -m Master &&
@@ -27,7 +27,7 @@ test_expect_success setup '
27
git checkout side &&
28
for f in text binary union
29
do
30
- echo Side >>$f && git add $f || break
30
+ echo Side >>$f && git add $f || return 1
31
done &&
32
test_tick &&
33
git commit -m Side &&
t/t6040-tracking-info.sh
+3
-4
@@ -12,10 +12,9 @@ advance () {
12
}
13
14
test_expect_success setup '
15
- for i in a b c;
16
- do
17
- advance $i || break
18
- done &&
15
+ advance a &&
16
+ advance b &&
17
+ advance c &&
18
git clone . test &&
19
(
20
cd test &&