Git fork

tests: fix broken &&-chains in compound statements

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 compound statements in order to reduce the
number of possible lurking bugs.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Eric Sunshine and committed by
Junio C Hamano
74d2f569 08495412

+95 -89
+6 -6
t/perf/p0005-status.sh
··· 24 24 test_expect_success "setup repo" ' 25 25 if git rev-parse --verify refs/heads/p0006-ballast^{commit} 26 26 then 27 - echo Assuming synthetic repo from many-files.sh 28 - git branch br_base master 29 - git branch br_ballast p0006-ballast 30 - git config --local core.sparsecheckout 1 27 + echo Assuming synthetic repo from many-files.sh && 28 + git branch br_base master && 29 + git branch br_ballast p0006-ballast && 30 + git config --local core.sparsecheckout 1 && 31 31 cat >.git/info/sparse-checkout <<-EOF 32 32 /* 33 33 !ballast/* 34 34 EOF 35 35 else 36 - echo Assuming non-synthetic repo... 37 - git branch br_base $(git rev-list HEAD | tail -n 1) 36 + echo Assuming non-synthetic repo... && 37 + git branch br_base $(git rev-list HEAD | tail -n 1) && 38 38 git branch br_ballast HEAD 39 39 fi && 40 40 git checkout -q br_ballast &&
+10 -10
t/perf/p0006-read-tree-checkout.sh
··· 24 24 test_expect_success "setup repo" ' 25 25 if git rev-parse --verify refs/heads/p0006-ballast^{commit} 26 26 then 27 - echo Assuming synthetic repo from many-files.sh 28 - git branch br_base master 29 - git branch br_ballast p0006-ballast^ 30 - git branch br_ballast_alias p0006-ballast^ 31 - git branch br_ballast_plus_1 p0006-ballast 32 - git config --local core.sparsecheckout 1 27 + echo Assuming synthetic repo from many-files.sh && 28 + git branch br_base master && 29 + git branch br_ballast p0006-ballast^ && 30 + git branch br_ballast_alias p0006-ballast^ && 31 + git branch br_ballast_plus_1 p0006-ballast && 32 + git config --local core.sparsecheckout 1 && 33 33 cat >.git/info/sparse-checkout <<-EOF 34 34 /* 35 35 !ballast/* 36 36 EOF 37 37 else 38 - echo Assuming non-synthetic repo... 39 - git branch br_base $(git rev-list HEAD | tail -n 1) 40 - git branch br_ballast HEAD^ || error "no ancestor commit from current head" 41 - git branch br_ballast_alias HEAD^ 38 + echo Assuming non-synthetic repo... && 39 + git branch br_base $(git rev-list HEAD | tail -n 1) && 40 + git branch br_ballast HEAD^ || error "no ancestor commit from current head" && 41 + git branch br_ballast_alias HEAD^ && 42 42 git branch br_ballast_plus_1 HEAD 43 43 fi && 44 44 git checkout -q br_ballast &&
+2 -2
t/perf/p0007-write-cache.sh
··· 9 9 test_expect_success "setup repo" ' 10 10 if git rev-parse --verify refs/heads/p0006-ballast^{commit} 11 11 then 12 - echo Assuming synthetic repo from many-files.sh 13 - git config --local core.sparsecheckout 1 12 + echo Assuming synthetic repo from many-files.sh && 13 + git config --local core.sparsecheckout 1 && 14 14 cat >.git/info/sparse-checkout <<-EOF 15 15 /* 16 16 !ballast/*
+1 -1
t/perf/p5302-pack-index.sh
··· 21 21 threads= && 22 22 while test $t -gt 0 23 23 do 24 - threads="$t $threads" 24 + threads="$t $threads" && 25 25 t=$((t / 2)) 26 26 done 27 27 '
+4 -4
t/perf/p5303-many-packs.sh
··· 126 126 # Measure pack loading with 10,000 packs. 127 127 test_expect_success 'generate lots of packs' ' 128 128 for i in $(test_seq 10000); do 129 - echo "blob" 130 - echo "data <<EOF" 131 - echo "blob $i" 132 - echo "EOF" 129 + echo "blob" && 130 + echo "data <<EOF" && 131 + echo "blob $i" && 132 + echo "EOF" && 133 133 echo "checkpoint" 134 134 done | 135 135 git -c fastimport.unpackLimit=0 fast-import
+2 -2
t/t1050-large.sh
··· 54 54 bad= count=0 idx= && 55 55 for p in .git/objects/pack/pack-*.pack 56 56 do 57 - count=$(( $count + 1 )) 57 + count=$(( $count + 1 )) && 58 58 if test_path_is_file "$p" && 59 59 idx=${p%.pack}.idx && test_path_is_file "$idx" 60 60 then ··· 78 78 bad= count=0 && 79 79 for p in .git/objects/pack/pack-*.pack 80 80 do 81 - count=$(( $count + 1 )) 81 + count=$(( $count + 1 )) && 82 82 if test_path_is_file "$p" && 83 83 idx=${p%.pack}.idx && test_path_is_file "$idx" 84 84 then
+1 -1
t/t1300-config.sh
··· 717 717 rm -f result && 718 718 for i in 1 2 3 4 719 719 do 720 - git config --bool --get bool.true$i >>result 720 + git config --bool --get bool.true$i >>result && 721 721 git config --bool --get bool.false$i >>result 722 722 done && 723 723 test_cmp expect result'
+2 -2
t/t1700-split-index.sh
··· 48 48 # NEEDSWORK: Stop hard-coding checksums. 49 49 if test "$indexversion" = "4" 50 50 then 51 - own=$(test_oid own_v4) 51 + own=$(test_oid own_v4) && 52 52 base=$(test_oid base_v4) 53 53 else 54 - own=$(test_oid own_v3) 54 + own=$(test_oid own_v3) && 55 55 base=$(test_oid base_v3) 56 56 fi && 57 57
+2 -2
t/t2200-add-update.sh
··· 150 150 { 151 151 for path in path1 path2 152 152 do 153 - echo "100644 $one 1 $path" 154 - echo "100644 $two 2 $path" 153 + echo "100644 $one 1 $path" && 154 + echo "100644 $two 2 $path" && 155 155 echo "100644 $three 3 $path" 156 156 done 157 157 echo "100644 $one 1 path3"
+1 -1
t/t3070-wildmatch.sh
··· 193 193 file=$(cat .git/expected_test_file) && 194 194 if should_create_test_file "$file" 195 195 then 196 - dirs=${file%/*} 196 + dirs=${file%/*} && 197 197 if test "$file" != "$dirs" 198 198 then 199 199 mkdir -p -- "$dirs" &&
+2 -2
t/t3700-add.sh
··· 141 141 test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' ' 142 142 for s in 1 2 3 143 143 do 144 - echo $s > stage$s 145 - echo "100755 $(git hash-object -w stage$s) $s file" 144 + echo $s > stage$s && 145 + echo "100755 $(git hash-object -w stage$s) $s file" && 146 146 echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s symlink" 147 147 done | git update-index --index-info && 148 148 git config core.filemode 0 &&
+1 -1
t/t4046-diff-unmerged.sh
··· 18 18 for t in o x 19 19 do 20 20 path="$b$o$t" && 21 - case "$path" in ooo) continue ;; esac 21 + case "$path" in ooo) continue ;; esac && 22 22 paths="$paths$path " && 23 23 p=" $path" && 24 24 case "$b" in x) echo "$m1$p" ;; esac &&
+2 -2
t/t4123-apply-shrink.sh
··· 45 45 echo Oops, should not have succeeded 46 46 false 47 47 else 48 - status=$? 49 - echo "Status was $status" 48 + status=$? && 49 + echo "Status was $status" && 50 50 if test -f .git/index.lock 51 51 then 52 52 echo Oops, should not have crashed
+10 -10
t/t4138-apply-ws-expansion.sh
··· 29 29 x=1 && 30 30 while test $x -lt $n 31 31 do 32 - printf "%63s%d\n" "" $x >>after 32 + printf "%63s%d\n" "" $x >>after && 33 33 x=$(( $x + 1 )) 34 34 done && 35 35 printf "\t%s\n" d e f >>after && ··· 40 40 x=1 && 41 41 while test $x -lt $n 42 42 do 43 - printf "%63s%d\n" "" $x >>expect-2 43 + printf "%63s%d\n" "" $x >>expect-2 && 44 44 x=$(( $x + 1 )) 45 45 done && 46 46 printf "%64s\n" d e f >>expect-2 && ··· 52 52 x=0 && 53 53 while test $x -lt $n 54 54 do 55 - printf "%63s%02d\n" "" $x >>after 55 + printf "%63s%02d\n" "" $x >>after && 56 56 x=$(( $x + 1 )) 57 57 done && 58 58 printf "\t%s\n" d e f >>after && ··· 63 63 x=0 && 64 64 while test $x -lt $n 65 65 do 66 - printf "%63s%02d\n" "" $x >>expect-3 66 + printf "%63s%02d\n" "" $x >>expect-3 && 67 67 x=$(( $x + 1 )) 68 68 done && 69 69 printf "%64s\n" d e f >>expect-3 && ··· 73 73 x=0 && 74 74 while test $x -lt 50 75 75 do 76 - printf "\t%02d\n" $x >>before 76 + printf "\t%02d\n" $x >>before && 77 77 x=$(( $x + 1 )) 78 78 done && 79 79 cat before >after && 80 80 printf "%64s\n" a b c >>after && 81 81 while test $x -lt 100 82 82 do 83 - printf "\t%02d\n" $x >>before 84 - printf "\t%02d\n" $x >>after 83 + printf "\t%02d\n" $x >>before && 84 + printf "\t%02d\n" $x >>after && 85 85 x=$(( $x + 1 )) 86 86 done && 87 87 test_expect_code 1 git diff --no-index before after >patch4.patch.raw && ··· 90 90 x=0 && 91 91 while test $x -lt 50 92 92 do 93 - printf "%63s%02d\n" "" $x >>test-4 93 + printf "%63s%02d\n" "" $x >>test-4 && 94 94 x=$(( $x + 1 )) 95 95 done && 96 96 cat test-4 >expect-4 && 97 97 printf "%64s\n" a b c >>expect-4 && 98 98 while test $x -lt 100 99 99 do 100 - printf "%63s%02d\n" "" $x >>test-4 101 - printf "%63s%02d\n" "" $x >>expect-4 100 + printf "%63s%02d\n" "" $x >>test-4 && 101 + printf "%63s%02d\n" "" $x >>expect-4 && 102 102 x=$(( $x + 1 )) 103 103 done && 104 104
+1 -1
t/t5302-pack-index.sh
··· 14 14 i=1 && 15 15 while test $i -le 100 16 16 do 17 - iii=$(printf "%03i" $i) 17 + iii=$(printf "%03i" $i) && 18 18 test-tool genrandom "bar" 200 > wide_delta_$iii && 19 19 test-tool genrandom "baz $iii" 50 >> wide_delta_$iii && 20 20 test-tool genrandom "foo"$i 100 > deep_delta_$iii &&
+10 -10
t/t5317-pack-objects-filter-objects.sh
··· 16 16 git init r1 && 17 17 for n in 1 2 3 4 5 18 18 do 19 - echo "This is file: $n" > r1/file.$n 20 - git -C r1 add file.$n 19 + echo "This is file: $n" > r1/file.$n && 20 + git -C r1 add file.$n && 21 21 git -C r1 commit -m "$n" 22 22 done 23 23 ' ··· 116 116 git init r2 && 117 117 for n in 1000 10000 118 118 do 119 - printf "%"$n"s" X > r2/large.$n 120 - git -C r2 add large.$n 119 + printf "%"$n"s" X > r2/large.$n && 120 + git -C r2 add large.$n && 121 121 git -C r2 commit -m "$n" 122 122 done 123 123 ' ··· 278 278 mkdir r3/dir1 && 279 279 for n in sparse1 sparse2 280 280 do 281 - echo "This is file: $n" > r3/$n 282 - git -C r3 add $n 283 - echo "This is file: dir1/$n" > r3/dir1/$n 281 + echo "This is file: $n" > r3/$n && 282 + git -C r3 add $n && 283 + echo "This is file: dir1/$n" > r3/dir1/$n && 284 284 git -C r3 add dir1/$n 285 285 done && 286 286 git -C r3 commit -m "sparse" && ··· 331 331 mkdir r4/dir1 && 332 332 for n in sparse1 sparse2 333 333 do 334 - echo "This is file: $n" > r4/$n 335 - git -C r4 add $n 336 - echo "This is file: dir1/$n" > r4/dir1/$n 334 + echo "This is file: $n" > r4/$n && 335 + git -C r4 add $n && 336 + echo "This is file: dir1/$n" > r4/dir1/$n && 337 337 git -C r4 add dir1/$n 338 338 done && 339 339 echo dir1/ >r4/pattern &&
+1 -1
t/t5571-pre-push-hook.sh
··· 117 117 nr=1000 118 118 while test $nr -lt 2000 119 119 do 120 - nr=$(( $nr + 1 )) 120 + nr=$(( $nr + 1 )) && 121 121 echo "create refs/heads/b/$nr $COMMIT3" 122 122 done 123 123 } | git update-ref --stdin
+9 -9
t/t5616-partial-clone.sh
··· 16 16 git init src && 17 17 for n in 1 2 3 4 18 18 do 19 - echo "This is file: $n" > src/file.$n.txt 20 - git -C src add file.$n.txt 21 - git -C src commit -m "file $n" 19 + echo "This is file: $n" > src/file.$n.txt && 20 + git -C src add file.$n.txt && 21 + git -C src commit -m "file $n" && 22 22 git -C src ls-files -s file.$n.txt >>temp 23 23 done && 24 24 awk -f print_2.awk <temp | sort >expect_1.oids && ··· 72 72 git -C src remote add srv "file://$(pwd)/srv.bare" && 73 73 for x in a b c d e 74 74 do 75 - echo "Mod file.1.txt $x" >>src/file.1.txt 76 - git -C src add file.1.txt 75 + echo "Mod file.1.txt $x" >>src/file.1.txt && 76 + git -C src add file.1.txt && 77 77 git -C src commit -m "mod $x" 78 78 done && 79 79 git -C src blame main -- file.1.txt >expect.blame && ··· 114 114 test_expect_success 'push new commits to server for file.2.txt' ' 115 115 for x in a b c d e f 116 116 do 117 - echo "Mod file.2.txt $x" >>src/file.2.txt 118 - git -C src add file.2.txt 117 + echo "Mod file.2.txt $x" >>src/file.2.txt && 118 + git -C src add file.2.txt && 119 119 git -C src commit -m "mod $x" 120 120 done && 121 121 git -C src push -u srv main ··· 135 135 test_expect_success 'push new commits to server for file.3.txt' ' 136 136 for x in a b c d e f 137 137 do 138 - echo "Mod file.3.txt $x" >>src/file.3.txt 139 - git -C src add file.3.txt 138 + echo "Mod file.3.txt $x" >>src/file.3.txt && 139 + git -C src add file.3.txt && 140 140 git -C src commit -m "mod $x" 141 141 done && 142 142 git -C src push -u srv main
+4 -4
t/t6005-rev-list-count.sh
··· 5 5 . ./test-lib.sh 6 6 7 7 test_expect_success 'setup' ' 8 - for n in 1 2 3 4 5 ; do \ 9 - echo $n > a ; \ 10 - git add a ; \ 11 - git commit -m "$n" ; \ 8 + for n in 1 2 3 4 5 ; do 9 + echo $n > a && 10 + git add a && 11 + git commit -m "$n" 12 12 done 13 13 ' 14 14
+1 -1
t/t6009-rev-list-parent.sh
··· 142 142 143 143 test_tick_keep=$test_tick && 144 144 for i in 1 2 3 4 5 6 7 8; do 145 - test_tick=$test_tick_keep 145 + test_tick=$test_tick_keep && 146 146 test_commit t$i 147 147 done && 148 148 git rev-list t1^! --not t$i >result &&
+7 -7
t/t6112-rev-list-filters-objects.sh
··· 16 16 git init r1 && 17 17 for n in 1 2 3 4 5 18 18 do 19 - echo "This is file: $n" > r1/file.$n 20 - git -C r1 add file.$n 19 + echo "This is file: $n" > r1/file.$n && 20 + git -C r1 add file.$n && 21 21 git -C r1 commit -m "$n" 22 22 done 23 23 ' ··· 73 73 git init r2 && 74 74 for n in 1000 10000 75 75 do 76 - printf "%"$n"s" X > r2/large.$n 77 - git -C r2 add large.$n 76 + printf "%"$n"s" X > r2/large.$n && 77 + git -C r2 add large.$n && 78 78 git -C r2 commit -m "$n" 79 79 done 80 80 ' ··· 245 245 mkdir r3/dir1 && 246 246 for n in sparse1 sparse2 247 247 do 248 - echo "This is file: $n" > r3/$n 249 - git -C r3 add $n 250 - echo "This is file: dir1/$n" > r3/dir1/$n 248 + echo "This is file: $n" > r3/$n && 249 + git -C r3 add $n && 250 + echo "This is file: dir1/$n" > r3/dir1/$n && 251 251 git -C r3 add dir1/$n 252 252 done && 253 253 git -C r3 commit -m "sparse" &&
+5 -2
t/t6120-describe.sh
··· 390 390 committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 391 391 data <<EOF 392 392 commit #$i 393 - EOF" 394 - test $i = 1 && echo "from refs/heads/main^0" 393 + EOF" && 394 + if test $i = 1 395 + then 396 + echo "from refs/heads/main^0" 397 + fi && 395 398 i=$(($i + 1)) 396 399 done | git fast-import && 397 400 git checkout main &&
+2 -2
t/t6407-merge-binary.sh
··· 47 47 echo Oops, should not have succeeded 48 48 false 49 49 else 50 - git ls-files -s >current 50 + git ls-files -s >current && 51 51 test_cmp expect current 52 52 fi 53 53 ' ··· 62 62 echo Oops, should not have succeeded 63 63 false 64 64 else 65 - git ls-files -s >current 65 + git ls-files -s >current && 66 66 test_cmp expect current 67 67 fi 68 68 '
+1 -1
t/t6412-merge-large-rename.sh
··· 47 47 git commit -a -m change=$n && 48 48 git checkout -b test$n HEAD^ && 49 49 for i in $(count $n); do 50 - git rm $i 50 + git rm $i && 51 51 make_text $i initial changed >$i.moved 52 52 done && 53 53 git add . &&
+5 -2
t/t7004-tag.sh
··· 1976 1976 committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 1977 1977 data <<EOF 1978 1978 commit #$i 1979 - EOF" 1980 - test $i = 1 && echo "from refs/heads/main^0" 1979 + EOF" && 1980 + if test $i = 1 1981 + then 1982 + echo "from refs/heads/main^0" 1983 + fi && 1981 1984 i=$(($i + 1)) 1982 1985 done | git fast-import && 1983 1986 git checkout main &&
+1 -1
t/t7519-status-fsmonitor.sh
··· 248 248 git config core.preloadIndex $preload_val && 249 249 if test $preload_val = true 250 250 then 251 - GIT_TEST_PRELOAD_INDEX=$preload_val; export GIT_TEST_PRELOAD_INDEX 251 + GIT_TEST_PRELOAD_INDEX=$preload_val && export GIT_TEST_PRELOAD_INDEX 252 252 else 253 253 sane_unset GIT_TEST_PRELOAD_INDEX 254 254 fi
+1 -1
t/t7602-merge-octopus-many.sh
··· 29 29 refs="" && 30 30 while test $i -le 30 31 31 do 32 - refs="$refs c$i" 32 + refs="$refs c$i" && 33 33 i=$(expr $i + 1) 34 34 done && 35 35 git merge $refs &&
+1 -1
t/t9130-git-svn-authors-file.sh
··· 59 59 git svn clone --authors-file=svn-authors -s "$svnrepo"/aa aa-work && 60 60 for i in bb ee cc 61 61 do 62 - branch="aa/branches/$i" 62 + branch="aa/branches/$i" && 63 63 svn_cmd mkdir -m "$branch" --username $i "$svnrepo/$branch" 64 64 done 65 65 '