Skip to content

Commit 9293aac

Browse files
committed
Merge branch 'rr/test-chaining'
* rr/test-chaining: t3401: use test_commit in setup t3401: modernize style t3040 (subprojects-basic): fix '&&' chaining, modernize style t1510 (worktree): fix '&&' chaining t3030 (merge-recursive): use test_expect_code test: fix '&&' chaining t3200 (branch): fix '&&' chaining
2 parents 33e7fef + 13c907c commit 9293aac

15 files changed

+123
-199
lines changed

t/t1007-hash-object.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do
189189
done
190190

191191
test_expect_success 'corrupt tree' '
192-
echo abc >malformed-tree
192+
echo abc >malformed-tree &&
193193
test_must_fail git hash-object -t tree malformed-tree
194194
'
195195

t/t1013-loose-object-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ assert_blob_equals() {
3434
}
3535

3636
test_expect_success setup '
37-
cp -R "$TEST_DIRECTORY/t1013/objects" .git/
37+
cp -R "$TEST_DIRECTORY/t1013/objects" .git/ &&
3838
git --version
3939
'
4040

t/t1300-repo-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cat > expect << EOF
3838
WhatEver = Second
3939
EOF
4040
test_expect_success 'similar section' '
41-
git config Cores.WhatEver Second
41+
git config Cores.WhatEver Second &&
4242
test_cmp expect .git/config
4343
'
4444

t/t1412-reflog-loop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_expect_success 'setup reflog with alternating commits' '
2020
'
2121

2222
test_expect_success 'reflog shows all entries' '
23-
cat >expect <<-\EOF
23+
cat >expect <<-\EOF &&
2424
topic@{0} reset: moving to two
2525
topic@{1} reset: moving to one
2626
topic@{2} reset: moving to two

t/t1501-worktree.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test_expect_success 'setup: helper for testing rev-parse' '
4848
'
4949

5050
test_expect_success 'setup: core.worktree = relative path' '
51-
unset GIT_WORK_TREE;
51+
sane_unset GIT_WORK_TREE &&
5252
GIT_DIR=repo.git &&
5353
GIT_CONFIG="$(pwd)"/$GIT_DIR/config &&
5454
export GIT_DIR GIT_CONFIG &&
@@ -89,7 +89,7 @@ test_expect_success 'subdir of work tree' '
8989
'
9090

9191
test_expect_success 'setup: core.worktree = absolute path' '
92-
unset GIT_WORK_TREE;
92+
sane_unset GIT_WORK_TREE &&
9393
GIT_DIR=$(pwd)/repo.git &&
9494
GIT_CONFIG=$GIT_DIR/config &&
9595
export GIT_DIR GIT_CONFIG &&
@@ -334,7 +334,7 @@ test_expect_success 'absolute pathspec should fail gracefully' '
334334
'
335335

336336
test_expect_success 'make_relative_path handles double slashes in GIT_DIR' '
337-
>dummy_file
337+
>dummy_file &&
338338
echo git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file &&
339339
git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file
340340
'

t/t1510-repo-setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' '
603603
# like case #6.
604604
605605
setup_repo 22a "$here/22a/.git" "" unset &&
606-
setup_repo 22ab . "" unset
606+
setup_repo 22ab . "" unset &&
607607
mkdir -p 22a/.git/sub 22a/sub &&
608608
mkdir -p 22ab/.git/sub 22ab/sub &&
609609
try_case 22a/.git unset . \
@@ -742,7 +742,7 @@ test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' '
742742
# Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case).
743743
test_expect_success '#29: setup' '
744744
setup_repo 29 non-existent gitfile true &&
745-
mkdir -p 29/sub/sub 29/wt/sub
745+
mkdir -p 29/sub/sub 29/wt/sub &&
746746
(
747747
cd 29 &&
748748
GIT_WORK_TREE="$here/29" &&

t/t1511-rev-parse-caret.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_description='tests for ref^{stuff}'
66

77
test_expect_success 'setup' '
88
echo blob >a-blob &&
9-
git tag -a -m blob blob-tag `git hash-object -w a-blob`
9+
git tag -a -m blob blob-tag `git hash-object -w a-blob` &&
1010
mkdir a-tree &&
1111
echo moreblobs >a-tree/another-blob &&
1212
git add . &&

t/t3030-merge-recursive.sh

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,7 @@ test_expect_success 'merge-recursive simple' '
285285
rm -fr [abcd] &&
286286
git checkout -f "$c2" &&
287287
288-
git merge-recursive "$c0" -- "$c2" "$c1"
289-
status=$?
290-
case "$status" in
291-
1)
292-
: happy
293-
;;
294-
*)
295-
echo >&2 "why status $status!!!"
296-
false
297-
;;
298-
esac
288+
test_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1"
299289
'
300290

301291
test_expect_success 'merge-recursive result' '
@@ -334,17 +324,7 @@ test_expect_success 'merge-recursive remove conflict' '
334324
rm -fr [abcd] &&
335325
git checkout -f "$c1" &&
336326
337-
git merge-recursive "$c0" -- "$c1" "$c5"
338-
status=$?
339-
case "$status" in
340-
1)
341-
: happy
342-
;;
343-
*)
344-
echo >&2 "why status $status!!!"
345-
false
346-
;;
347-
esac
327+
test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5"
348328
'
349329

350330
test_expect_success 'merge-recursive remove conflict' '
@@ -388,17 +368,7 @@ test_expect_success 'merge-recursive d/f conflict' '
388368
git reset --hard &&
389369
git checkout -f "$c1" &&
390370
391-
git merge-recursive "$c0" -- "$c1" "$c4"
392-
status=$?
393-
case "$status" in
394-
1)
395-
: happy
396-
;;
397-
*)
398-
echo >&2 "why status $status!!!"
399-
false
400-
;;
401-
esac
371+
test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4"
402372
'
403373

404374
test_expect_success 'merge-recursive d/f conflict result' '
@@ -422,17 +392,7 @@ test_expect_success 'merge-recursive d/f conflict the other way' '
422392
git reset --hard &&
423393
git checkout -f "$c4" &&
424394
425-
git merge-recursive "$c0" -- "$c4" "$c1"
426-
status=$?
427-
case "$status" in
428-
1)
429-
: happy
430-
;;
431-
*)
432-
echo >&2 "why status $status!!!"
433-
false
434-
;;
435-
esac
395+
test_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1"
436396
'
437397

438398
test_expect_success 'merge-recursive d/f conflict result the other way' '
@@ -456,17 +416,7 @@ test_expect_success 'merge-recursive d/f conflict' '
456416
git reset --hard &&
457417
git checkout -f "$c1" &&
458418
459-
git merge-recursive "$c0" -- "$c1" "$c6"
460-
status=$?
461-
case "$status" in
462-
1)
463-
: happy
464-
;;
465-
*)
466-
echo >&2 "why status $status!!!"
467-
false
468-
;;
469-
esac
419+
test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6"
470420
'
471421

472422
test_expect_success 'merge-recursive d/f conflict result' '
@@ -490,17 +440,7 @@ test_expect_success 'merge-recursive d/f conflict' '
490440
git reset --hard &&
491441
git checkout -f "$c6" &&
492442
493-
git merge-recursive "$c0" -- "$c6" "$c1"
494-
status=$?
495-
case "$status" in
496-
1)
497-
: happy
498-
;;
499-
*)
500-
echo >&2 "why status $status!!!"
501-
false
502-
;;
503-
esac
443+
test_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1"
504444
'
505445

506446
test_expect_success 'merge-recursive d/f conflict result' '

t/t3040-subprojects-basic.sh

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,81 @@
33
test_description='Basic subproject functionality'
44
. ./test-lib.sh
55

6-
test_expect_success 'Super project creation' \
7-
': >Makefile &&
8-
git add Makefile &&
9-
git commit -m "Superproject created"'
10-
11-
12-
cat >expected <<EOF
13-
:000000 160000 00000... A sub1
14-
:000000 160000 00000... A sub2
15-
EOF
16-
test_expect_success 'create subprojects' \
17-
'mkdir sub1 &&
18-
( cd sub1 && git init && : >Makefile && git add * &&
19-
git commit -q -m "subproject 1" ) &&
20-
mkdir sub2 &&
21-
( cd sub2 && git init && : >Makefile && git add * &&
22-
git commit -q -m "subproject 2" ) &&
23-
git update-index --add sub1 &&
24-
git add sub2 &&
25-
git commit -q -m "subprojects added" &&
26-
git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
27-
test_cmp expected current'
28-
29-
git branch save HEAD
30-
31-
test_expect_success 'check if fsck ignores the subprojects' \
32-
'git fsck --full'
33-
34-
test_expect_success 'check if commit in a subproject detected' \
35-
'( cd sub1 &&
36-
echo "all:" >>Makefile &&
37-
echo " true" >>Makefile &&
38-
git commit -q -a -m "make all" ) && {
39-
git diff-files --exit-code
40-
test $? = 1
41-
}'
42-
43-
test_expect_success 'check if a changed subproject HEAD can be committed' \
44-
'git commit -q -a -m "sub1 changed" && {
45-
git diff-tree --exit-code HEAD^ HEAD
46-
test $? = 1
47-
}'
48-
49-
test_expect_success 'check if diff-index works for subproject elements' \
50-
'git diff-index --exit-code --cached save -- sub1
51-
test $? = 1'
52-
53-
test_expect_success 'check if diff-tree works for subproject elements' \
54-
'git diff-tree --exit-code HEAD^ HEAD -- sub1
55-
test $? = 1'
56-
57-
test_expect_success 'check if git diff works for subproject elements' \
58-
'git diff --exit-code HEAD^ HEAD
59-
test $? = 1'
60-
61-
test_expect_success 'check if clone works' \
62-
'git ls-files -s >expected &&
63-
git clone -l -s . cloned &&
64-
( cd cloned && git ls-files -s ) >current &&
65-
test_cmp expected current'
66-
67-
test_expect_success 'removing and adding subproject' \
68-
'git update-index --force-remove -- sub2 &&
69-
mv sub2 sub3 &&
70-
git add sub3 &&
71-
git commit -q -m "renaming a subproject" && {
72-
git diff -M --name-status --exit-code HEAD^ HEAD
73-
test $? = 1
74-
}'
6+
test_expect_success 'setup: create superproject' '
7+
: >Makefile &&
8+
git add Makefile &&
9+
git commit -m "Superproject created"
10+
'
11+
12+
test_expect_success 'setup: create subprojects' '
13+
mkdir sub1 &&
14+
( cd sub1 && git init && : >Makefile && git add * &&
15+
git commit -q -m "subproject 1" ) &&
16+
mkdir sub2 &&
17+
( cd sub2 && git init && : >Makefile && git add * &&
18+
git commit -q -m "subproject 2" ) &&
19+
git update-index --add sub1 &&
20+
git add sub2 &&
21+
git commit -q -m "subprojects added" &&
22+
git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
23+
git branch save HEAD &&
24+
cat >expected <<-\EOF &&
25+
:000000 160000 00000... A sub1
26+
:000000 160000 00000... A sub2
27+
EOF
28+
test_cmp expected current
29+
'
30+
31+
test_expect_success 'check if fsck ignores the subprojects' '
32+
git fsck --full
33+
'
34+
35+
test_expect_success 'check if commit in a subproject detected' '
36+
( cd sub1 &&
37+
echo "all:" >>Makefile &&
38+
echo " true" >>Makefile &&
39+
git commit -q -a -m "make all" ) &&
40+
test_expect_code 1 git diff-files --exit-code
41+
'
42+
43+
test_expect_success 'check if a changed subproject HEAD can be committed' '
44+
git commit -q -a -m "sub1 changed" &&
45+
test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD
46+
'
47+
48+
test_expect_success 'check if diff-index works for subproject elements' '
49+
test_expect_code 1 git diff-index --exit-code --cached save -- sub1
50+
'
51+
52+
test_expect_success 'check if diff-tree works for subproject elements' '
53+
test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD -- sub1
54+
'
55+
56+
test_expect_success 'check if git diff works for subproject elements' '
57+
test_expect_code 1 git diff --exit-code HEAD^ HEAD
58+
'
59+
60+
test_expect_success 'check if clone works' '
61+
git ls-files -s >expected &&
62+
git clone -l -s . cloned &&
63+
( cd cloned && git ls-files -s ) >current &&
64+
test_cmp expected current
65+
'
66+
67+
test_expect_success 'removing and adding subproject' '
68+
git update-index --force-remove -- sub2 &&
69+
mv sub2 sub3 &&
70+
git add sub3 &&
71+
git commit -q -m "renaming a subproject" &&
72+
test_expect_code 1 git diff -M --name-status --exit-code HEAD^ HEAD
73+
'
7574

7675
# the index must contain the object name the HEAD of the
7776
# subproject sub1 was at the point "save"
78-
test_expect_success 'checkout in superproject' \
79-
'git checkout save &&
80-
git diff-index --exit-code --raw --cached save -- sub1'
77+
test_expect_success 'checkout in superproject' '
78+
git checkout save &&
79+
git diff-index --exit-code --raw --cached save -- sub1
80+
'
8181

8282
# just interesting what happened...
8383
# git diff --name-status -M save master

t/t3200-branch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success \
2222

2323
test_expect_success \
2424
'git branch --help should not have created a bogus branch' '
25-
git branch --help </dev/null >/dev/null 2>/dev/null;
25+
test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
2626
test_path_is_missing .git/refs/heads/--help
2727
'
2828

@@ -88,7 +88,7 @@ test_expect_success \
8888
test_expect_success \
8989
'git branch -m n/n n should work' \
9090
'git branch -l n/n &&
91-
git branch -m n/n n
91+
git branch -m n/n n &&
9292
test_path_is_file .git/logs/refs/heads/n'
9393

9494
test_expect_success 'git branch -m o/o o should fail when o/p exists' '

0 commit comments

Comments
 (0)