Skip to content

Commit ed40ec5

Browse files
drafnelgitster
authored andcommitted
t0001,t1510,t3301: use sane_unset which always returns with status 0
On some shells (like /usr/xpg4/bin/sh on Solaris), unset will exit non-zero when passed the name of a variable that has not been set. Use sane_unset instead so that the return value of unset can be ignored while the && linkage of the test script can be preserved. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e83c267 commit ed40ec5

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

t/t0001-init.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test_expect_success 'plain' '
3535

3636
test_expect_success 'plain nested in bare' '
3737
(
38-
unset GIT_DIR GIT_WORK_TREE &&
38+
sane_unset GIT_DIR GIT_WORK_TREE &&
3939
git init --bare bare-ancestor.git &&
4040
cd bare-ancestor.git &&
4141
mkdir plain-nested &&
@@ -47,7 +47,7 @@ test_expect_success 'plain nested in bare' '
4747

4848
test_expect_success 'plain through aliased command, outside any git repo' '
4949
(
50-
unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
50+
sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
5151
HOME=$(pwd)/alias-config &&
5252
export HOME &&
5353
mkdir alias-config &&
@@ -65,7 +65,7 @@ test_expect_success 'plain through aliased command, outside any git repo' '
6565

6666
test_expect_failure 'plain nested through aliased command' '
6767
(
68-
unset GIT_DIR GIT_WORK_TREE &&
68+
sane_unset GIT_DIR GIT_WORK_TREE &&
6969
git init plain-ancestor-aliased &&
7070
cd plain-ancestor-aliased &&
7171
echo "[alias] aliasedinit = init" >>.git/config &&
@@ -78,7 +78,7 @@ test_expect_failure 'plain nested through aliased command' '
7878

7979
test_expect_failure 'plain nested in bare through aliased command' '
8080
(
81-
unset GIT_DIR GIT_WORK_TREE &&
81+
sane_unset GIT_DIR GIT_WORK_TREE &&
8282
git init --bare bare-ancestor-aliased.git &&
8383
cd bare-ancestor-aliased.git &&
8484
echo "[alias] aliasedinit = init" >>config &&

t/t1510-repo-setup.sh

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test_repo() {
8080
# - cwd can't be outside worktree
8181

8282
test_expect_success '#0: setup' '
83-
unset GIT_DIR GIT_WORK_TREE &&
83+
sane_unset GIT_DIR GIT_WORK_TREE &&
8484
mkdir 0 0/sub &&
8585
cd 0 && git init && cd ..
8686
'
@@ -123,7 +123,7 @@ EOF
123123
# GIT_WORK_TREE is ignored -> #0
124124

125125
test_expect_success '#1: setup' '
126-
unset GIT_DIR GIT_WORK_TREE &&
126+
sane_unset GIT_DIR GIT_WORK_TREE &&
127127
mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
128128
cd 1 &&
129129
git init &&
@@ -174,7 +174,7 @@ EOF
174174
# - cwd can't be outside worktree
175175

176176
test_expect_success '#2: setup' '
177-
unset GIT_DIR GIT_WORK_TREE &&
177+
sane_unset GIT_DIR GIT_WORK_TREE &&
178178
mkdir 2 2/sub &&
179179
cd 2 && git init && cd ..
180180
'
@@ -241,7 +241,7 @@ EOF
241241
# - cwd can be outside worktree
242242

243243
test_expect_success '#3: setup' '
244-
unset GIT_DIR GIT_WORK_TREE &&
244+
sane_unset GIT_DIR GIT_WORK_TREE &&
245245
mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
246246
cd 3 && git init && cd ..
247247
'
@@ -504,7 +504,7 @@ EOF
504504
# core.worktree is ignored -> #0
505505

506506
test_expect_success '#4: setup' '
507-
unset GIT_DIR GIT_WORK_TREE &&
507+
sane_unset GIT_DIR GIT_WORK_TREE &&
508508
mkdir 4 4/sub &&
509509
cd 4 &&
510510
git init &&
@@ -550,7 +550,7 @@ EOF
550550
# GIT_WORK_TREE/core.worktree are ignored -> #0
551551

552552
test_expect_success '#5: setup' '
553-
unset GIT_DIR GIT_WORK_TREE &&
553+
sane_unset GIT_DIR GIT_WORK_TREE &&
554554
mkdir 5 5/sub &&
555555
cd 5 &&
556556
git init &&
@@ -602,7 +602,7 @@ EOF
602602
# - cwd can be outside worktree
603603

604604
test_expect_success '#6: setup' '
605-
unset GIT_DIR GIT_WORK_TREE &&
605+
sane_unset GIT_DIR GIT_WORK_TREE &&
606606
mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
607607
cd 6 && git init && cd ..
608608
'
@@ -889,7 +889,7 @@ EOF
889889
# core.worktree is overridden by GIT_WORK_TREE -> #3
890890

891891
test_expect_success '#7: setup' '
892-
unset GIT_DIR GIT_WORK_TREE &&
892+
sane_unset GIT_DIR GIT_WORK_TREE &&
893893
mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
894894
cd 7 &&
895895
git init &&
@@ -1155,7 +1155,7 @@ EOF
11551155
# #0 except that git_dir is set by .git file
11561156

11571157
test_expect_success '#8: setup' '
1158-
unset GIT_DIR GIT_WORK_TREE &&
1158+
sane_unset GIT_DIR GIT_WORK_TREE &&
11591159
mkdir 8 8/sub &&
11601160
cd 8 &&
11611161
git init &&
@@ -1202,7 +1202,7 @@ EOF
12021202
# #1 except that git_dir is set by .git file
12031203

12041204
test_expect_success '#9: setup' '
1205-
unset GIT_DIR GIT_WORK_TREE &&
1205+
sane_unset GIT_DIR GIT_WORK_TREE &&
12061206
mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
12071207
cd 9 &&
12081208
git init &&
@@ -1251,7 +1251,7 @@ EOF
12511251
# #2 except that git_dir is set by .git file
12521252

12531253
test_expect_success '#10: setup' '
1254-
unset GIT_DIR GIT_WORK_TREE &&
1254+
sane_unset GIT_DIR GIT_WORK_TREE &&
12551255
mkdir 10 10/sub &&
12561256
cd 10 &&
12571257
git init &&
@@ -1318,7 +1318,7 @@ EOF
13181318
# #3 except that git_dir is set by .git file
13191319

13201320
test_expect_success '#11: setup' '
1321-
unset GIT_DIR GIT_WORK_TREE &&
1321+
sane_unset GIT_DIR GIT_WORK_TREE &&
13221322
mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
13231323
cd 11 &&
13241324
git init &&
@@ -1586,7 +1586,7 @@ EOF
15861586

15871587

15881588
test_expect_success '#12: setup' '
1589-
unset GIT_DIR GIT_WORK_TREE &&
1589+
sane_unset GIT_DIR GIT_WORK_TREE &&
15901590
mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
15911591
cd 12 &&
15921592
git init &&
@@ -1634,7 +1634,7 @@ EOF
16341634
# #5 except that git_dir is set by .git file
16351635

16361636
test_expect_success '#13: setup' '
1637-
unset GIT_DIR GIT_WORK_TREE &&
1637+
sane_unset GIT_DIR GIT_WORK_TREE &&
16381638
mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
16391639
cd 13 &&
16401640
git init &&
@@ -1684,7 +1684,7 @@ EOF
16841684
# #6 except that git_dir is set by .git file
16851685

16861686
test_expect_success '#14: setup' '
1687-
unset GIT_DIR GIT_WORK_TREE &&
1687+
sane_unset GIT_DIR GIT_WORK_TREE &&
16881688
mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
16891689
cd 14 &&
16901690
git init &&
@@ -1975,7 +1975,7 @@ EOF
19751975
# #7 except that git_dir is set by .git file
19761976

19771977
test_expect_success '#15: setup' '
1978-
unset GIT_DIR GIT_WORK_TREE &&
1978+
sane_unset GIT_DIR GIT_WORK_TREE &&
19791979
mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
19801980
cd 15 &&
19811981
git init &&
@@ -2247,7 +2247,7 @@ EOF
22472247
# - cwd can't be outside worktree
22482248

22492249
test_expect_success '#16.1: setup' '
2250-
unset GIT_DIR GIT_WORK_TREE &&
2250+
sane_unset GIT_DIR GIT_WORK_TREE &&
22512251
mkdir 16 16/sub &&
22522252
cd 16 &&
22532253
git init &&
@@ -2378,7 +2378,7 @@ EOF
23782378
# GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
23792379

23802380
test_expect_success '#17.1: setup' '
2381-
unset GIT_DIR GIT_WORK_TREE &&
2381+
sane_unset GIT_DIR GIT_WORK_TREE &&
23822382
mkdir 17 17/sub &&
23832383
cd 17 &&
23842384
git init &&
@@ -2511,7 +2511,7 @@ EOF
25112511
# - cwd can't be outside worktree
25122512

25132513
test_expect_success '#18: setup' '
2514-
unset GIT_DIR GIT_WORK_TREE &&
2514+
sane_unset GIT_DIR GIT_WORK_TREE &&
25152515
mkdir 18 18/sub &&
25162516
cd 18 &&
25172517
git init &&
@@ -2578,7 +2578,7 @@ EOF
25782578
# bare repo is overridden by GIT_WORK_TREE -> #3
25792579

25802580
test_expect_success '#19: setup' '
2581-
unset GIT_DIR GIT_WORK_TREE &&
2581+
sane_unset GIT_DIR GIT_WORK_TREE &&
25822582
mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
25832583
cd 19 &&
25842584
git init &&
@@ -2844,7 +2844,7 @@ EOF
28442844
# core.worktree is ignored -> #16.1
28452845

28462846
test_expect_success '#20.1: setup' '
2847-
unset GIT_DIR GIT_WORK_TREE &&
2847+
sane_unset GIT_DIR GIT_WORK_TREE &&
28482848
mkdir 20 20/sub &&
28492849
cd 20 &&
28502850
git init &&
@@ -2972,7 +2972,7 @@ EOF
29722972
# GIT_WORK_TREE/core.worktree are ignored -> #20.1
29732973

29742974
test_expect_success '#21.1: setup' '
2975-
unset GIT_DIR GIT_WORK_TREE &&
2975+
sane_unset GIT_DIR GIT_WORK_TREE &&
29762976
mkdir 21 21/sub &&
29772977
cd 21 &&
29782978
git init &&
@@ -3108,7 +3108,7 @@ EOF
31083108
# - cwd can be outside worktree
31093109

31103110
test_expect_success '#22.1: setup' '
3111-
unset GIT_DIR GIT_WORK_TREE &&
3111+
sane_unset GIT_DIR GIT_WORK_TREE &&
31123112
mkdir 22 &&
31133113
cd 22 &&
31143114
git init &&
@@ -3439,7 +3439,7 @@ test_expect_success '#22.2: at root' '
34393439
# core.worktree is overridden by GIT_WORK_TREE -> #19
34403440

34413441
test_expect_success '#23: setup' '
3442-
unset GIT_DIR GIT_WORK_TREE &&
3442+
sane_unset GIT_DIR GIT_WORK_TREE &&
34433443
mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
34443444
cd 23 &&
34453445
git init &&
@@ -3706,7 +3706,7 @@ EOF
37063706
# #16.2 except git_dir is set according to .git file
37073707

37083708
test_expect_success '#24: setup' '
3709-
unset GIT_DIR GIT_WORK_TREE &&
3709+
sane_unset GIT_DIR GIT_WORK_TREE &&
37103710
mkdir 24 24/sub &&
37113711
cd 24 &&
37123712
git init &&
@@ -3754,7 +3754,7 @@ EOF
37543754
# #17.2 except git_dir is set according to .git file
37553755

37563756
test_expect_success '#25: setup' '
3757-
unset GIT_DIR GIT_WORK_TREE &&
3757+
sane_unset GIT_DIR GIT_WORK_TREE &&
37583758
mkdir 25 25/sub &&
37593759
cd 25 &&
37603760
git init &&
@@ -3804,7 +3804,7 @@ EOF
38043804
# #18 except git_dir is set according to .git file
38053805

38063806
test_expect_success '#26: setup' '
3807-
unset GIT_DIR GIT_WORK_TREE &&
3807+
sane_unset GIT_DIR GIT_WORK_TREE &&
38083808
mkdir 26 26/sub &&
38093809
cd 26 &&
38103810
git init &&
@@ -3872,7 +3872,7 @@ EOF
38723872
# #19 except git_dir is set according to .git file
38733873

38743874
test_expect_success '#27: setup' '
3875-
unset GIT_DIR GIT_WORK_TREE &&
3875+
sane_unset GIT_DIR GIT_WORK_TREE &&
38763876
mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
38773877
cd 27 &&
38783878
git init &&
@@ -4140,7 +4140,7 @@ EOF
41404140
# core.worktree is ignored -> #24
41414141

41424142
test_expect_success '#28: setup' '
4143-
unset GIT_DIR GIT_WORK_TREE &&
4143+
sane_unset GIT_DIR GIT_WORK_TREE &&
41444144
mkdir 28 28/sub &&
41454145
cd 28 &&
41464146
git init &&
@@ -4189,7 +4189,7 @@ EOF
41894189
# GIT_WORK_TREE/core.worktree are ignored -> #28
41904190

41914191
test_expect_success '#29: setup' '
4192-
unset GIT_DIR GIT_WORK_TREE &&
4192+
sane_unset GIT_DIR GIT_WORK_TREE &&
41934193
mkdir 29 29/sub &&
41944194
cd 29 &&
41954195
git init &&
@@ -4239,7 +4239,7 @@ EOF
42394239
# core.worktree and core.bare conflict, won't fly.
42404240

42414241
test_expect_success '#30: setup' '
4242-
unset GIT_DIR GIT_WORK_TREE &&
4242+
sane_unset GIT_DIR GIT_WORK_TREE &&
42434243
mkdir 30 &&
42444244
cd 30 &&
42454245
git init &&
@@ -4278,7 +4278,7 @@ test_expect_success '#30: at root' '
42784278
# #23 except git_dir is set according to .git file
42794279

42804280
test_expect_success '#31: setup' '
4281-
unset GIT_DIR GIT_WORK_TREE &&
4281+
sane_unset GIT_DIR GIT_WORK_TREE &&
42824282
mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
42834283
cd 31 &&
42844284
git init &&

t/t3301-notes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' '
10671067

10681068
test_expect_success 'git notes get-ref (no overrides)' '
10691069
git config --unset core.notesRef &&
1070-
unset GIT_NOTES_REF &&
1070+
sane_unset GIT_NOTES_REF &&
10711071
test "$(git notes get-ref)" = "refs/notes/commits"
10721072
'
10731073

0 commit comments

Comments
 (0)