Skip to content

Commit c576868

Browse files
sunshinecogitster
authored andcommitted
tests: fix broken &&-chains in $(...) command substitutions
The top-level &&-chain checker built into t/test-lib.sh causes tests to magically exit with code 117 if the &&-chain is broken. However, it has the shortcoming that the magic does not work within `{...}` groups, `(...)` subshells, `$(...)` substitutions, or within bodies of compound statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed` partly fills in the gap by catching broken &&-chains in `(...)` subshells, but bugs can still lurk behind broken &&-chains in the other cases. Fix broken &&-chains in `$(...)` command substitutions in order to reduce the number of possible lurking bugs. Signed-off-by: Eric Sunshine <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 74d2f56 commit c576868

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

contrib/subtree/t/t7900-subtree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ test_expect_success 'subtree descendant check' '
14451445
) &&
14461446
test_create_commit "$test_count" folder_subtree/0 &&
14471447
test_create_commit "$test_count" folder_subtree/b &&
1448-
cherry=$(cd "$test_count"; git rev-parse HEAD) &&
1448+
cherry=$(cd "$test_count" && git rev-parse HEAD) &&
14491449
(
14501450
cd "$test_count" &&
14511451
git checkout branch

t/t0005-signals.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
4848
'
4949

5050
test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
51-
OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
51+
OUT=$( ((trap "" PIPE && large_git; echo $? 1>&3) | :) 3>&1 ) &&
5252
test_match_signal 13 "$OUT"
5353
'
5454

t/t0060-path-utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
216216
mkdir second &&
217217
ln -s ../first second/other &&
218218
mkdir third &&
219-
dir="$(cd .git; pwd -P)" &&
219+
dir="$(cd .git && pwd -P)" &&
220220
dir2=third/../second/other/.git &&
221221
test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
222222
file="$dir"/index &&
223223
test "$file" = "$(test-tool path-utils real_path $dir2/index)" &&
224224
basename=blub &&
225225
test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
226226
ln -s ../first/file .git/syml &&
227-
sym="$(cd first; pwd -P)"/file &&
227+
sym="$(cd first && pwd -P)"/file &&
228228
test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
229229
'
230230

t/t1006-cat-file.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,23 @@ done
211211
test_expect_success "--batch-check for a non-existent named object" '
212212
test "foobar42 missing
213213
foobar84 missing" = \
214-
"$( ( echo foobar42; echo_without_newline foobar84; ) | git cat-file --batch-check)"
214+
"$( ( echo foobar42 && echo_without_newline foobar84 ) | git cat-file --batch-check)"
215215
'
216216

217217
test_expect_success "--batch-check for a non-existent hash" '
218218
test "0000000000000000000000000000000000000042 missing
219219
0000000000000000000000000000000000000084 missing" = \
220-
"$( ( echo 0000000000000000000000000000000000000042;
221-
echo_without_newline 0000000000000000000000000000000000000084; ) |
220+
"$( ( echo 0000000000000000000000000000000000000042 &&
221+
echo_without_newline 0000000000000000000000000000000000000084 ) |
222222
git cat-file --batch-check)"
223223
'
224224

225225
test_expect_success "--batch for an existent and a non-existent hash" '
226226
test "$tag_sha1 tag $tag_size
227227
$tag_content
228228
0000000000000000000000000000000000000000 missing" = \
229-
"$( ( echo $tag_sha1;
230-
echo_without_newline 0000000000000000000000000000000000000000; ) |
229+
"$( ( echo $tag_sha1 &&
230+
echo_without_newline 0000000000000000000000000000000000000000 ) |
231231
git cat-file --batch)"
232232
'
233233

t/t3600-rm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft (induce S
265265

266266
test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' '
267267
choke_git_rm_setup &&
268-
OUT=$( ((trap "" PIPE; git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
268+
OUT=$( ((trap "" PIPE && git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
269269
test_match_signal 13 "$OUT" &&
270270
test_path_is_missing .git/index.lock
271271
'

t/t7010-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test_expect_success 'setup deeper work tree' '
137137

138138
test_expect_success 'add a directory outside the work tree' '(
139139
cd tester &&
140-
d1="$(cd .. ; pwd)" &&
140+
d1="$(cd .. && pwd)" &&
141141
test_must_fail git add "$d1"
142142
)'
143143

0 commit comments

Comments
 (0)