Skip to content

Commit 1faff2c

Browse files
committed
tests: export GIT_DIR=. after cd into bare repos
As part of the preparation for `safe.bareRepository` defaulting to `explicit` (see 8d1a744), add `GIT_DIR=. && export GIT_DIR &&` right after `cd <bare> &&` so that subsequent commands access the bare repo explicitly rather than relying on implicit discovery. Here is a command-line to help verify this commit mechanically (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: strip GIT_DIR export gsub(/ && GIT_DIR=[.] && export GIT_DIR/, "", new) if (old[n++] != new) print old[n-1] " != " new }' Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 6172b4c commit 1faff2c

Some content is hidden

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

50 files changed

+123
-123
lines changed

t/annotate-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test_expect_success 'blame with --contents' '
8686
test_expect_success 'blame with --contents in a bare repo' '
8787
git clone --bare . bare-contents.git &&
8888
(
89-
cd bare-contents.git &&
89+
cd bare-contents.git && GIT_DIR=. && export GIT_DIR &&
9090
echo "1A quick brown fox jumps over the" >contents &&
9191
check_count --contents=contents A 1
9292
)
@@ -101,7 +101,7 @@ test_expect_success 'blame with --contents changed' '
101101
test_expect_success 'blame in a bare repo without starting commit' '
102102
git clone --bare . bare.git &&
103103
(
104-
cd bare.git &&
104+
cd bare.git && GIT_DIR=. && export GIT_DIR &&
105105
check_count A 2
106106
)
107107
'

t/lib-bitmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ basic_bitmap_tests () {
207207
rm -fr partial-clone.git &&
208208
git clone --no-local --bare --filter=blob:none . partial-clone.git &&
209209
(
210-
cd partial-clone.git &&
210+
cd partial-clone.git && GIT_DIR=. && export GIT_DIR &&
211211
pack=$(echo objects/pack/*.pack) &&
212212
git verify-pack -v "$pack" >have &&
213213
awk "/blob/ { print \$1 }" <have >blobs &&

t/lib-proto-disable.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_allow_var () {
1717

1818
test_expect_success "fetch $desc (enabled)" '
1919
(
20-
cd tmp.git &&
20+
cd tmp.git && GIT_DIR=. && export GIT_DIR &&
2121
GIT_ALLOW_PROTOCOL=$proto &&
2222
export GIT_ALLOW_PROTOCOL &&
2323
git fetch
@@ -26,7 +26,7 @@ test_allow_var () {
2626

2727
test_expect_success "push $desc (enabled)" '
2828
(
29-
cd tmp.git &&
29+
cd tmp.git && GIT_DIR=. && export GIT_DIR &&
3030
GIT_ALLOW_PROTOCOL=$proto &&
3131
export GIT_ALLOW_PROTOCOL &&
3232
git push origin HEAD:pushed
@@ -35,7 +35,7 @@ test_allow_var () {
3535

3636
test_expect_success "push $desc (disabled)" '
3737
(
38-
cd tmp.git &&
38+
cd tmp.git && GIT_DIR=. && export GIT_DIR &&
3939
GIT_ALLOW_PROTOCOL=none &&
4040
export GIT_ALLOW_PROTOCOL &&
4141
test_must_fail git push origin HEAD:pushed
@@ -44,7 +44,7 @@ test_allow_var () {
4444

4545
test_expect_success "fetch $desc (disabled)" '
4646
(
47-
cd tmp.git &&
47+
cd tmp.git && GIT_DIR=. && export GIT_DIR &&
4848
GIT_ALLOW_PROTOCOL=none &&
4949
export GIT_ALLOW_PROTOCOL &&
5050
test_must_fail git fetch
@@ -119,7 +119,7 @@ test_config () {
119119

120120
test_expect_success "push $desc (disabled)" '
121121
(
122-
cd tmp.git &&
122+
cd tmp.git && GIT_DIR=. && export GIT_DIR &&
123123
GIT_PROTOCOL_FROM_USER=0 &&
124124
export GIT_PROTOCOL_FROM_USER &&
125125
test_must_fail git -c protocol.$proto.allow=user push origin HEAD:pushed
@@ -128,7 +128,7 @@ test_config () {
128128

129129
test_expect_success "fetch $desc (disabled)" '
130130
(
131-
cd tmp.git &&
131+
cd tmp.git && GIT_DIR=. && export GIT_DIR &&
132132
GIT_PROTOCOL_FROM_USER=0 &&
133133
export GIT_PROTOCOL_FROM_USER &&
134134
test_must_fail git -c protocol.$proto.allow=user fetch

t/t1006-cat-file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ test_expect_success 'clean up broken objects' '
804804
test_expect_success 'cat-file -t and -s on corrupt loose object' '
805805
git init --bare corrupt-loose.git &&
806806
(
807-
cd corrupt-loose.git &&
807+
cd corrupt-loose.git && GIT_DIR=. && export GIT_DIR &&
808808
809809
# Setup and create the empty blob and its path
810810
empty_path=$(git rev-parse --git-path objects/$(test_oid_to_path "$EMPTY_BLOB")) &&

t/t1450-fsck.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ remove_object () {
5353
test_expect_success 'object with hash mismatch' '
5454
git init --bare hash-mismatch &&
5555
(
56-
cd hash-mismatch &&
56+
cd hash-mismatch && GIT_DIR=. && export GIT_DIR &&
5757
5858
oid=$(echo blob | git hash-object -w --stdin) &&
5959
oldoid=$oid &&
@@ -75,7 +75,7 @@ test_expect_success 'object with hash mismatch' '
7575
test_expect_success 'zlib corrupt loose object output ' '
7676
git init --bare corrupt-loose-output &&
7777
(
78-
cd corrupt-loose-output &&
78+
cd corrupt-loose-output && GIT_DIR=. && export GIT_DIR &&
7979
oid=$(git hash-object -w --stdin --literally </dev/null) &&
8080
oidf=objects/$(test_oid_to_path "$oid") &&
8181
chmod +w $oidf &&
@@ -1064,7 +1064,7 @@ test_expect_success PERL_TEST_HELPERS 'detect corrupt index file in fsck' '
10641064
test_expect_success 'fsck error and recovery on invalid object type' '
10651065
git init --bare garbage-type &&
10661066
(
1067-
cd garbage-type &&
1067+
cd garbage-type && GIT_DIR=. && export GIT_DIR &&
10681068
10691069
garbage_blob=$(loose_obj objects garbage </dev/null) &&
10701070

t/t1512-rev-parse-disambiguation.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test_cmp_failed_rev_parse () {
3939
test_expect_success 'ambiguous blob output' '
4040
git init --bare blob.prefix &&
4141
(
42-
cd blob.prefix &&
42+
cd blob.prefix && GIT_DIR=. && export GIT_DIR &&
4343
4444
# Both start with "dead..", under both SHA-1 and SHA-256
4545
echo brocdnra | git hash-object -w --stdin &&
@@ -65,7 +65,7 @@ test_expect_success 'ambiguous blob output' '
6565
test_expect_success 'ambiguous loose bad object parsed as OBJ_BAD' '
6666
git init --bare blob.bad &&
6767
(
68-
cd blob.bad &&
68+
cd blob.bad && GIT_DIR=. && export GIT_DIR &&
6969
7070
# Both have the prefix "bad0"
7171
echo xyzfaowcoh | loose_obj objects bad &&
@@ -81,7 +81,7 @@ test_expect_success 'ambiguous loose bad object parsed as OBJ_BAD' '
8181
test_expect_success POSIXPERM 'ambigous zlib corrupt loose blob' '
8282
git init --bare blob.corrupt &&
8383
(
84-
cd blob.corrupt &&
84+
cd blob.corrupt && GIT_DIR=. && export GIT_DIR &&
8585
8686
# Both have the prefix "cafe"
8787
echo bnkxmdwz | git hash-object -w --stdin &&

t/t2400-worktree-add.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ test_expect_success '"add" from a bare repo' '
177177

178178
test_expect_success 'checkout from a bare repo without "add"' '
179179
(
180-
cd bare &&
180+
cd bare && GIT_DIR=. && export GIT_DIR &&
181181
test_must_fail git checkout main
182182
)
183183
'

t/t3451-history-reword.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ test_expect_success 'can reword in a bare repo' '
150150
test_commit -C repo first &&
151151
git clone --bare repo repo.git &&
152152
(
153-
cd repo.git &&
153+
cd repo.git && GIT_DIR=. && export GIT_DIR &&
154154
reword_with_message HEAD <<-EOF &&
155155
reworded
156156
EOF

t/t4203-mailmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
432432
test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
433433
git clone --bare non-bare bare &&
434434
(
435-
cd bare &&
435+
cd bare && GIT_DIR=. && export GIT_DIR &&
436436
cat >expect <<-\EOF &&
437437
1 Fake Name
438438
EOF

t/t5001-archive-attr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ test_expect_exists worktree2/ignored-by-tree
127127
test_expect_missing worktree2/ignored-by-worktree
128128

129129
test_expect_success 'git archive vs. bare' '
130-
(cd bare && git archive HEAD) >bare-archive.tar &&
130+
(cd bare && GIT_DIR=. && export GIT_DIR && git archive HEAD) >bare-archive.tar &&
131131
test_cmp_bin archive.tar bare-archive.tar
132132
'
133133

134134
test_expect_success 'git archive with worktree attributes, bare' '
135-
(cd bare &&
135+
(cd bare && GIT_DIR=. && export GIT_DIR &&
136136
git -c attr.tree=HEAD archive --worktree-attributes HEAD) >bare-worktree.tar &&
137137
(mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) <bare-worktree.tar
138138
'

0 commit comments

Comments
 (0)