Skip to content

Commit fdf364c

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 6380576 commit fdf364c

Some content is hidden

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

52 files changed

+124
-124
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/t1400-update-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test_expect_success setup '
2929
git checkout --orphan main &&
3030
create_test_commits "" &&
3131
mkdir $bare &&
32-
cd $bare &&
32+
cd $bare && GIT_DIR=. && export GIT_DIR &&
3333
git init --bare -b main &&
3434
create_test_commits "bare" &&
3535
cd - && sane_unset GIT_DIR

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/t1800-hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ test_expect_success 'server hooks expect stdout redirected to stderr' '
533533
test_when_finished "rm -f stdout.actual stderr.actual" &&
534534
git init --bare remote-server &&
535535
git remote add origin-server remote-server &&
536-
cd remote-server &&
536+
cd remote-server && GIT_DIR=. && export GIT_DIR &&
537537
setup_hooks pre-receive update post-receive post-update &&
538538
cd .. && sane_unset GIT_DIR &&
539539
git push origin-server HEAD:new-branch >stdout.actual 2>stderr.actual &&

t/t2400-worktree-add.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ test_expect_success '"add" from a bare repo' '
180180

181181
test_expect_success 'checkout from a bare repo without "add"' '
182182
(
183-
cd bare &&
183+
cd bare && GIT_DIR=. && export GIT_DIR &&
184184
test_must_fail git checkout main
185185
)
186186
'
@@ -205,7 +205,7 @@ test_expect_success '"add" default branch of a bare repo' '
205205
test_expect_success '"add" to bare repo with worktree config' '
206206
(
207207
git clone --bare . bare3 &&
208-
cd bare3 &&
208+
cd bare3 && GIT_DIR=. && export GIT_DIR &&
209209
git config extensions.worktreeconfig true &&
210210
211211
# Add config values that are erroneous to have in

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

0 commit comments

Comments
 (0)