Skip to content

Commit dc8aa4e

Browse files
committed
tests: use --git-dir instead of -C for bare repos
As part of the preparation for `safe.bareRepository` defaulting to `explicit` (see 8d1a744), replace `git -C <bare>` with `git --git-dir=<bare>`. The `-C` flag triggers implicit bare repository discovery, whereas `--git-dir` specifies the repository location explicitly. This commit can be verified mechanically by invoking this command-line (the awk script undoes the transformation on the new lines; empty output is success): git diff HEAD^! | awk ' /^diff/,/^\+\+\+/ { next } /^-/ { old[m++] = substr($0,2) } /^\+/ { new = substr($0,2) # undo: --git-dir=X -> -C X if (match(new, /--git-dir=([^ ]*)/, a)) { gsub(/--git-dir=[^ ]*/, "-C " a[1], new) } if (old[n++] != new) print old[n-1] " != " new }' Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 714c6d8 commit dc8aa4e

File tree

77 files changed

+383
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+383
-383
lines changed

t/lib-diff-alternative.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ EOF
131131
'
132132

133133
test_expect_success "diff from attributes with bare repo with source" '
134-
git -C bare.git --attr-source=branchA -c diff.driver.algorithm=myers \
134+
git --git-dir=bare.git --attr-source=branchA -c diff.driver.algorithm=myers \
135135
-c diff.driverA.algorithm=$STRATEGY \
136136
diff HEAD:file1 HEAD:file2 >output &&
137137
test_cmp expect output
138138
'
139139

140140
test_expect_success "diff from attributes with bare repo with invalid source" '
141-
test_must_fail git -C bare.git --attr-source=invalid-branch diff \
141+
test_must_fail git --git-dir=bare.git --attr-source=invalid-branch diff \
142142
HEAD:file1 HEAD:file2
143143
'
144144

t/lib-proto-disable.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@ test_config () {
8383
'
8484

8585
test_expect_success "fetch $desc (enabled)" '
86-
git -C tmp.git -c protocol.$proto.allow=always fetch
86+
git --git-dir=tmp.git -c protocol.$proto.allow=always fetch
8787
'
8888

8989
test_expect_success "push $desc (enabled)" '
90-
git -C tmp.git -c protocol.$proto.allow=always push origin HEAD:pushed
90+
git --git-dir=tmp.git -c protocol.$proto.allow=always push origin HEAD:pushed
9191
'
9292

9393
test_expect_success "push $desc (disabled)" '
94-
test_must_fail git -C tmp.git -c protocol.$proto.allow=never push origin HEAD:pushed
94+
test_must_fail git --git-dir=tmp.git -c protocol.$proto.allow=never push origin HEAD:pushed
9595
'
9696

9797
test_expect_success "fetch $desc (disabled)" '
98-
test_must_fail git -C tmp.git -c protocol.$proto.allow=never fetch
98+
test_must_fail git --git-dir=tmp.git -c protocol.$proto.allow=never fetch
9999
'
100100

101101
test_expect_success "clone $desc (disabled)" '
@@ -110,11 +110,11 @@ test_config () {
110110
'
111111

112112
test_expect_success "fetch $desc (enabled)" '
113-
git -C tmp.git -c protocol.$proto.allow=user fetch
113+
git --git-dir=tmp.git -c protocol.$proto.allow=user fetch
114114
'
115115

116116
test_expect_success "push $desc (enabled)" '
117-
git -C tmp.git -c protocol.$proto.allow=user push origin HEAD:pushed
117+
git --git-dir=tmp.git -c protocol.$proto.allow=user push origin HEAD:pushed
118118
'
119119

120120
test_expect_success "push $desc (disabled)" '
@@ -153,22 +153,22 @@ test_config () {
153153

154154
test_expect_success "fetch $desc (enabled)" '
155155
test_config_global protocol.allow always &&
156-
git -C tmp.git fetch
156+
git --git-dir=tmp.git fetch
157157
'
158158

159159
test_expect_success "push $desc (enabled)" '
160160
test_config_global protocol.allow always &&
161-
git -C tmp.git push origin HEAD:pushed
161+
git --git-dir=tmp.git push origin HEAD:pushed
162162
'
163163

164164
test_expect_success "push $desc (disabled)" '
165165
test_config_global protocol.allow never &&
166-
test_must_fail git -C tmp.git push origin HEAD:pushed
166+
test_must_fail git --git-dir=tmp.git push origin HEAD:pushed
167167
'
168168

169169
test_expect_success "fetch $desc (disabled)" '
170170
test_config_global protocol.allow never &&
171-
test_must_fail git -C tmp.git fetch
171+
test_must_fail git --git-dir=tmp.git fetch
172172
'
173173

174174
test_expect_success "clone $desc (disabled)" '

t/t0003-attributes.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,11 @@ test_expect_success 'bare repo no longer defaults to reading .gitattributes from
401401
git clone --bare test bare_with_gitattribute &&
402402
403403
echo "f/path: test: unspecified" >expect &&
404-
git -C bare_with_gitattribute check-attr test -- f/path >actual &&
404+
git --git-dir=bare_with_gitattribute check-attr test -- f/path >actual &&
405405
test_cmp expect actual &&
406406
407407
echo "f/path: test: val" >expect &&
408-
git -C bare_with_gitattribute -c attr.tree=HEAD \
408+
git --git-dir=bare_with_gitattribute -c attr.tree=HEAD \
409409
check-attr test -- f/path >actual &&
410410
test_cmp expect actual
411411
'

t/t0410-partial-clone.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,10 @@ test_expect_success 'exact rename does not need to fetch the blob lazily' '
643643
test_config -C repo uploadpack.allowanysha1inwant 1 &&
644644
645645
git clone --filter=blob:none --bare "file://$(pwd)/repo" partial.git &&
646-
git -C partial.git rev-list --objects --missing=print HEAD >out &&
646+
git --git-dir=partial.git rev-list --objects --missing=print HEAD >out &&
647647
grep "[?]$FILE_HASH" out &&
648-
git -C partial.git log --follow -- new-file.txt &&
649-
git -C partial.git rev-list --objects --missing=print HEAD >out &&
648+
git --git-dir=partial.git log --follow -- new-file.txt &&
649+
git --git-dir=partial.git rev-list --objects --missing=print HEAD >out &&
650650
grep "[?]$FILE_HASH" out
651651
'
652652

@@ -661,30 +661,30 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' '
661661
FILE_HASH=$(git -C full rev-parse HEAD:file.txt) &&
662662
663663
# Sanity check that the file is missing
664-
git -C partial.git rev-list --objects --missing=print HEAD >out &&
664+
git --git-dir=partial.git rev-list --objects --missing=print HEAD >out &&
665665
grep "[?]$FILE_HASH" out &&
666666
667667
# The no-lazy-fetch mechanism prevents Git from fetching
668668
test_must_fail env GIT_NO_LAZY_FETCH=1 \
669-
git -C partial.git cat-file -e "$FILE_HASH" &&
669+
git --git-dir=partial.git cat-file -e "$FILE_HASH" &&
670670
671671
# The same with command line option to "git"
672-
test_must_fail git --no-lazy-fetch -C partial.git cat-file -e "$FILE_HASH" &&
672+
test_must_fail git --no-lazy-fetch --git-dir=partial.git cat-file -e "$FILE_HASH" &&
673673
674674
# The same, forcing a subprocess via an alias
675-
test_must_fail git --no-lazy-fetch -C partial.git \
675+
test_must_fail git --no-lazy-fetch --git-dir=partial.git \
676676
-c alias.foo="!git cat-file" foo -e "$FILE_HASH" &&
677677
678678
# Sanity check that the file is still missing
679-
git -C partial.git rev-list --objects --missing=print HEAD >out &&
679+
git --git-dir=partial.git rev-list --objects --missing=print HEAD >out &&
680680
grep "[?]$FILE_HASH" out &&
681681
682682
git -C full cat-file -s "$FILE_HASH" >expect &&
683683
test-tool partial-clone object-info partial.git "$FILE_HASH" >actual &&
684684
test_cmp expect actual &&
685685
686686
# Sanity check that the file is now present
687-
git -C partial.git rev-list --objects --missing=print HEAD >out &&
687+
git --git-dir=partial.git rev-list --objects --missing=print HEAD >out &&
688688
! grep "[?]$FILE_HASH" out
689689
'
690690

t/t0600-reffiles-backend.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,14 @@ test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
428428
ln -s ../.git/objects subdir/objects &&
429429
ln -s ../.git/packed-refs subdir/packed-refs &&
430430
431-
git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
431+
git --git-dir=subdir rev-parse --absolute-git-dir >subdir.dir &&
432432
git rev-parse --absolute-git-dir >our.dir &&
433433
! test_cmp subdir.dir our.dir &&
434434
435-
git -C subdir log &&
436-
git -C subdir branch rename-src &&
435+
git --git-dir=subdir log &&
436+
git --git-dir=subdir branch rename-src &&
437437
git rev-parse rename-src >expect &&
438-
git -C subdir branch -m rename-src rename-dest &&
438+
git --git-dir=subdir branch -m rename-src rename-dest &&
439439
git rev-parse rename-dest >actual &&
440440
test_cmp expect actual &&
441441
git branch -D rename-dest

t/t1022-read-tree-partial-clone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test_expect_success 'read-tree in partial clone prefetches in one batch' '
1818
git -C server config uploadpack.allowfilter 1 &&
1919
git -C server config uploadpack.allowanysha1inwant 1 &&
2020
git clone --bare --filter=blob:none "file://$(pwd)/server" client &&
21-
GIT_TRACE_PACKET="$(pwd)/trace" git -C client read-tree $TREE $TREE &&
21+
GIT_TRACE_PACKET="$(pwd)/trace" git --git-dir=client read-tree $TREE $TREE &&
2222
2323
# "done" marks the end of negotiation (once per fetch). Expect that
2424
# only one fetch occurs.

t/t1050-large.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ test_expect_success 'enter "large" codepath, with small core.bigFileThreshold' '
2828
test_when_finished "rm -rf repo" &&
2929
3030
git init --bare repo &&
31-
echo large | git -C repo hash-object -w --stdin &&
32-
git -C repo -c core.bigfilethreshold=4 fsck
31+
echo large | git --git-dir=repo hash-object -w --stdin &&
32+
git --git-dir=repo -c core.bigfilethreshold=4 fsck
3333
'
3434

3535
# add a large file with different settings

t/t1091-sparse-checkout-builtin.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -951,32 +951,32 @@ test_expect_success 'setup bare repo' '
951951
git clone --bare "file://$(pwd)/repo" bare
952952
'
953953
test_expect_success 'list fails outside work tree' '
954-
test_must_fail git -C bare sparse-checkout list 2>err &&
954+
test_must_fail git --git-dir=bare sparse-checkout list 2>err &&
955955
test_grep "this operation must be run in a work tree" err
956956
'
957957

958958
test_expect_success 'add fails outside work tree' '
959-
test_must_fail git -C bare sparse-checkout add deeper 2>err &&
959+
test_must_fail git --git-dir=bare sparse-checkout add deeper 2>err &&
960960
test_grep "this operation must be run in a work tree" err
961961
'
962962

963963
test_expect_success 'set fails outside work tree' '
964-
test_must_fail git -C bare sparse-checkout set deeper 2>err &&
964+
test_must_fail git --git-dir=bare sparse-checkout set deeper 2>err &&
965965
test_grep "this operation must be run in a work tree" err
966966
'
967967

968968
test_expect_success 'init fails outside work tree' '
969-
test_must_fail git -C bare sparse-checkout init 2>err &&
969+
test_must_fail git --git-dir=bare sparse-checkout init 2>err &&
970970
test_grep "this operation must be run in a work tree" err
971971
'
972972

973973
test_expect_success 'reapply fails outside work tree' '
974-
test_must_fail git -C bare sparse-checkout reapply 2>err &&
974+
test_must_fail git --git-dir=bare sparse-checkout reapply 2>err &&
975975
test_grep "this operation must be run in a work tree" err
976976
'
977977

978978
test_expect_success 'disable fails outside work tree' '
979-
test_must_fail git -C bare sparse-checkout disable 2>err &&
979+
test_must_fail git --git-dir=bare sparse-checkout disable 2>err &&
980980
test_grep "this operation must be run in a work tree" err
981981
'
982982

@@ -990,7 +990,7 @@ test_expect_success 'check-rules cone mode' '
990990
deep/deeper1/deepest
991991
EOF
992992
993-
git -C bare ls-tree -r --name-only HEAD >all-files &&
993+
git --git-dir=bare ls-tree -r --name-only HEAD >all-files &&
994994
git --git-dir=bare sparse-checkout check-rules --cone \
995995
--rules-file rules >check-rules-file <all-files &&
996996
@@ -1012,7 +1012,7 @@ test_expect_success 'check-rules non-cone mode' '
10121012
deep/deeper1/deepest/a
10131013
EOF
10141014
1015-
git -C bare ls-tree -r --name-only HEAD >all-files &&
1015+
git --git-dir=bare ls-tree -r --name-only HEAD >all-files &&
10161016
git --git-dir=bare sparse-checkout check-rules --no-cone --rules-file rules\
10171017
>check-rules-file <all-files &&
10181018

t/t1305-config-include.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ test_expect_success 'conditional include, onbranch, implicit /** for /' '
350350

351351
test_expect_success 'include cycles are detected' '
352352
git init --bare cycle &&
353-
git -C cycle config include.path cycle &&
353+
git --git-dir=cycle config include.path cycle &&
354354
git config -f cycle/cycle include.path config &&
355-
test_must_fail git -C cycle config --get-all test.value 2>stderr &&
355+
test_must_fail git --git-dir=cycle config --get-all test.value 2>stderr &&
356356
grep "exceeded maximum include depth" stderr
357357
'
358358

t/t1400-update-ref.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ test_expect_success 'update-ref creates reflogs with --create-reflog' '
124124
'
125125

126126
test_expect_success 'creates no reflog in bare repository' '
127-
git -C $bare update-ref $m $bareA &&
128-
git -C $bare rev-parse $bareA >expect &&
129-
git -C $bare rev-parse $m >actual &&
127+
git --git-dir=$bare update-ref $m $bareA &&
128+
git --git-dir=$bare rev-parse $bareA >expect &&
129+
git --git-dir=$bare rev-parse $m >actual &&
130130
test_cmp expect actual &&
131-
test_must_fail git -C $bare reflog exists $m
131+
test_must_fail git --git-dir=$bare reflog exists $m
132132
'
133133

134134
test_expect_success 'core.logAllRefUpdates=true creates reflog in bare repository' '
135-
test_when_finished "git -C $bare config --unset core.logAllRefUpdates && \
135+
test_when_finished "git --git-dir=$bare config --unset core.logAllRefUpdates && \
136136
test-tool ref-store main delete-reflog $m" &&
137-
git -C $bare config core.logAllRefUpdates true &&
138-
git -C $bare update-ref $m $bareB &&
139-
git -C $bare rev-parse $bareB >expect &&
140-
git -C $bare rev-parse $m >actual &&
137+
git --git-dir=$bare config core.logAllRefUpdates true &&
138+
git --git-dir=$bare update-ref $m $bareB &&
139+
git --git-dir=$bare rev-parse $bareB >expect &&
140+
git --git-dir=$bare rev-parse $m >actual &&
141141
test_cmp expect actual &&
142-
git -C $bare reflog exists $m
142+
git --git-dir=$bare reflog exists $m
143143
'
144144

145145
test_expect_success 'core.logAllRefUpdates=true does not create reflog by default' '

0 commit comments

Comments
 (0)