Skip to content

Commit ea3431d

Browse files
committed
Merge branch 'standalone-fixes'
2 parents 6e8d538 + e1f6c2a commit ea3431d

13 files changed

Lines changed: 62 additions & 83 deletions

t/t0001-init.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ check_config () {
2020
return 1
2121
fi
2222

23-
bare=$(cd "$1" && git config --bool core.bare)
24-
worktree=$(cd "$1" && git config core.worktree) ||
23+
bare=$(git --git-dir="$1" config --bool core.bare)
24+
worktree=$(git --git-dir="$1" config core.worktree) ||
2525
worktree=unset
2626

2727
test "$bare" = "$2" && test "$worktree" = "$3" || {
@@ -77,6 +77,7 @@ test_expect_success 'plain nested through aliased command' '
7777
'
7878

7979
test_expect_success 'plain nested in bare through aliased command' '
80+
test_config_global safe.bareRepository all &&
8081
(
8182
git init --bare bare-ancestor-aliased.git &&
8283
cd bare-ancestor-aliased.git &&

t/t0003-attributes.sh

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,14 @@ test_expect_success 'setup bare' '
346346

347347
test_expect_success 'bare repository: check that .gitattribute is ignored' '
348348
(
349-
cd bare.git &&
350-
(
351-
echo "f test=f" &&
352-
echo "a/i test=a/i"
353-
) >.gitattributes &&
354-
attr_check f unspecified &&
355-
attr_check a/f unspecified &&
356-
attr_check a/c/f unspecified &&
357-
attr_check a/i unspecified &&
358-
attr_check subdir/a/i unspecified
359-
)
349+
echo "f test=f" &&
350+
echo "a/i test=a/i"
351+
) >bare.git/.gitattributes &&
352+
attr_check f unspecified --git-dir=bare.git &&
353+
attr_check a/f unspecified --git-dir=bare.git &&
354+
attr_check a/c/f unspecified --git-dir=bare.git &&
355+
attr_check a/i unspecified --git-dir=bare.git &&
356+
attr_check subdir/a/i unspecified --git-dir=bare.git
360357
'
361358

362359
bad_attr_source_err="fatal: bad --attr-source or GIT_ATTR_SOURCE"
@@ -449,41 +446,32 @@ test_expect_success 'diff without repository with attr source' '
449446
'
450447

451448
test_expect_success 'bare repository: with --source' '
452-
(
453-
cd bare.git &&
454-
attr_check_source foo/bar/f f tag-1 &&
455-
attr_check_source foo/bar/a/i n tag-1 &&
456-
attr_check_source foo/bar/f unspecified tag-2 &&
457-
attr_check_source foo/bar/a/i m tag-2 &&
458-
attr_check_source foo/bar/g g tag-2 &&
459-
attr_check_source foo/bar/g unspecified tag-1
460-
)
449+
attr_check_source foo/bar/f f tag-1 --git-dir=bare.git &&
450+
attr_check_source foo/bar/a/i n tag-1 --git-dir=bare.git &&
451+
attr_check_source foo/bar/f unspecified tag-2 --git-dir=bare.git &&
452+
attr_check_source foo/bar/a/i m tag-2 --git-dir=bare.git &&
453+
attr_check_source foo/bar/g g tag-2 --git-dir=bare.git &&
454+
attr_check_source foo/bar/g unspecified tag-1 --git-dir=bare.git
461455
'
462456

463457
test_expect_success 'bare repository: check that --cached honors index' '
464-
(
465-
cd bare.git &&
466-
GIT_INDEX_FILE=../.git/index \
467-
git check-attr --cached --stdin --all <../stdin-all |
468-
sort >actual &&
469-
test_cmp ../specified-all actual
470-
)
458+
GIT_INDEX_FILE=.git/index \
459+
git --git-dir=bare.git check-attr --cached --stdin --all <stdin-all |
460+
sort >actual &&
461+
test_cmp specified-all actual
471462
'
472463

473464
test_expect_success 'bare repository: test info/attributes' '
465+
mkdir -p bare.git/info &&
474466
(
475-
cd bare.git &&
476-
mkdir info &&
477-
(
478-
echo "f test=f" &&
479-
echo "a/i test=a/i"
480-
) >info/attributes &&
481-
attr_check f f &&
482-
attr_check a/f f &&
483-
attr_check a/c/f f &&
484-
attr_check a/i a/i &&
485-
attr_check subdir/a/i unspecified
486-
)
467+
echo "f test=f" &&
468+
echo "a/i test=a/i"
469+
) >bare.git/info/attributes &&
470+
attr_check f f --git-dir=bare.git &&
471+
attr_check a/f f --git-dir=bare.git &&
472+
attr_check a/c/f f --git-dir=bare.git &&
473+
attr_check a/i a/i --git-dir=bare.git &&
474+
attr_check subdir/a/i unspecified --git-dir=bare.git
487475
'
488476

489477
test_expect_success 'binary macro expanded by -a' '

t/t0056-git-C.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ test_expect_success 'Order should not matter: "--git-dir=a.git -C c" is equivale
5757
test_expect_success 'Effect on --work-tree option: "-C c/a.git --work-tree=../a" is equivalent to "--work-tree=c/a --git-dir=c/a.git"' '
5858
rm c/a/a.txt &&
5959
git --git-dir=c/a.git --work-tree=c/a status >expected &&
60+
test_config_global safe.bareRepository all &&
6061
git -C c/a.git --work-tree=../a status >actual &&
6162
test_cmp expected actual
6263
'
6364

6465
test_expect_success 'Order should not matter: "--work-tree=../a -C c/a.git" is equivalent to "-C c/a.git --work-tree=../a"' '
66+
test_config_global safe.bareRepository all &&
6567
git -C c/a.git --work-tree=../a status >expected &&
6668
git --work-tree=../a -C c/a.git status >actual &&
6769
test_cmp expected actual

t/t1020-subdirectory.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ test_expect_success 'no file/rev ambiguity check inside a bare repo (explicit GI
177177
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
178178
test_when_finished "rm -fr foo.git" &&
179179
git clone -s --bare .git foo.git &&
180-
(
181-
cd foo.git &&
182-
git show -s HEAD
183-
)
180+
git --git-dir=foo.git show -s HEAD
184181
'
185182

186183
test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '

t/t1900-repo-info.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ test_repo_info () {
2020
repo_name=$3
2121
key=$4
2222
expected_value=$5
23+
repo_flag=${6:--C}
2324

2425
test_expect_success "setup: $label" '
2526
eval "$init_command $repo_name"
2627
'
2728

2829
test_expect_success "lines: $label" '
2930
echo "$key=$expected_value" > expect &&
30-
git -C "$repo_name" repo info "$key" >actual &&
31+
git $repo_flag "$repo_name" repo info "$key" >actual &&
3132
test_cmp expect actual
3233
'
3334

3435
test_expect_success "nul: $label" '
3536
printf "%s\n%s\0" "$key" "$expected_value" >expect &&
36-
git -C "$repo_name" repo info --format=nul "$key" >actual &&
37+
git $repo_flag "$repo_name" repo info --format=nul "$key" >actual &&
3738
test_cmp_bin expect actual
3839
'
3940
}
@@ -48,7 +49,7 @@ test_repo_info 'bare repository = false is retrieved correctly' \
4849
'git init' 'nonbare' 'layout.bare' 'false'
4950

5051
test_repo_info 'bare repository = true is retrieved correctly' \
51-
'git init --bare' 'bare' 'layout.bare' 'true'
52+
'git init --bare' 'bare' 'layout.bare' 'true' '--git-dir'
5253

5354
test_repo_info 'shallow repository = false is retrieved correctly' \
5455
'git init' 'nonshallow' 'layout.shallow' 'false'

t/t2400-worktree-add.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,8 @@ test_expect_success 'not die on re-checking out current branch' '
171171
'
172172

173173
test_expect_success '"add" from a bare repo' '
174-
(
175-
git clone --bare . bare &&
176-
cd bare &&
177-
git worktree add -b bare-main ../there2 main
178-
)
174+
git clone --bare . bare &&
175+
git -C bare --git-dir=. worktree add -b bare-main ../there2 main
179176
'
180177

181178
test_expect_success 'checkout from a bare repo without "add"' '
@@ -186,15 +183,11 @@ test_expect_success 'checkout from a bare repo without "add"' '
186183
'
187184

188185
test_expect_success '"add" default branch of a bare repo' '
189-
(
190-
git clone --bare . bare2 &&
191-
cd bare2 &&
192-
git worktree add ../there3 main &&
193-
cd ../there3 &&
194-
# Simple check that a Git command does not
195-
# immediately fail with the current setup
196-
git status
197-
) &&
186+
git clone --bare . bare2 &&
187+
git -C bare2 --git-dir=. worktree add ../there3 main &&
188+
# Simple check that a Git command does not
189+
# immediately fail with the current setup
190+
git status &&
198191
cat >expect <<-EOF &&
199192
init.t
200193
EOF

t/t2406-worktree-repair.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test_expect_success 'repair .git file from bare.git' '
8484
git -C bare.git worktree add --detach ../corrupt &&
8585
git -C corrupt rev-parse --absolute-git-dir >expect &&
8686
rm -f corrupt/.git &&
87-
git -C bare.git worktree repair &&
87+
git -C bare.git --git-dir=. worktree repair &&
8888
git -C corrupt rev-parse --absolute-git-dir >actual &&
8989
test_cmp expect actual
9090
'

t/t5503-tagfollow.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,13 @@ test_expect_success 'new clone fetch main and tags' '
168168

169169
test_expect_success 'fetch specific OID with tag following' '
170170
git init --bare clone3.git &&
171-
(
172-
cd clone3.git &&
173-
git remote add origin .. &&
174-
git fetch origin $B:refs/heads/main &&
171+
git --git-dir=clone3.git remote add origin "$PWD" &&
172+
git --git-dir=clone3.git fetch origin $B:refs/heads/main &&
175173
176-
git -C .. for-each-ref >expect &&
177-
git for-each-ref >actual &&
174+
git for-each-ref >expect &&
175+
git --git-dir=clone3.git for-each-ref >actual &&
178176
179-
test_cmp expect actual
180-
)
177+
test_cmp expect actual
181178
'
182179

183180
test_done

t/t5505-remote.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ test_expect_success 'add --mirror && prune' '
561561
mkdir mirror &&
562562
(
563563
cd mirror &&
564-
git init --bare &&
564+
git init --bare && GIT_DIR=. && export GIT_DIR &&
565565
git remote add --mirror -f origin ../one
566566
) &&
567567
(
@@ -583,7 +583,7 @@ test_expect_success 'add --mirror setting HEAD' '
583583
mkdir headmirror &&
584584
(
585585
cd headmirror &&
586-
git init --bare -b notmain &&
586+
git init --bare -b notmain && GIT_DIR=. && export GIT_DIR &&
587587
git remote add --mirror -f origin ../one &&
588588
test "$(git symbolic-ref HEAD)" = "refs/heads/main"
589589
)

t/t5509-fetch-push-namespaces.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ test_expect_success 'mirroring a repository using a ref namespace' '
8888

8989
test_expect_success 'hide namespaced refs with transfer.hideRefs' '
9090
GIT_NAMESPACE=namespace \
91-
git -C pushee -c transfer.hideRefs=refs/tags \
92-
ls-remote "ext::git %s ." >actual &&
91+
git --git-dir=pushee -c transfer.hideRefs=refs/tags \
92+
ls-remote "ext::git %s pushee" >actual &&
9393
printf "$commit1\trefs/heads/main\n" >expected &&
9494
test_cmp expected actual
9595
'
9696

9797
test_expect_success 'check that transfer.hideRefs does not match unstripped refs' '
9898
git -C pushee pack-refs --all &&
9999
GIT_NAMESPACE=namespace \
100-
git -C pushee -c transfer.hideRefs=refs/namespaces/namespace/refs/tags \
101-
ls-remote "ext::git %s ." >actual &&
100+
git --git-dir=pushee -c transfer.hideRefs=refs/namespaces/namespace/refs/tags \
101+
ls-remote "ext::git %s pushee" >actual &&
102102
printf "$commit1\trefs/heads/main\n" >expected &&
103103
printf "$commit0\trefs/tags/0\n" >>expected &&
104104
printf "$commit1\trefs/tags/1\n" >>expected &&
@@ -107,8 +107,8 @@ test_expect_success 'check that transfer.hideRefs does not match unstripped refs
107107

108108
test_expect_success 'hide full refs with transfer.hideRefs' '
109109
GIT_NAMESPACE=namespace \
110-
git -C pushee -c transfer.hideRefs="^refs/namespaces/namespace/refs/tags" \
111-
ls-remote "ext::git %s ." >actual &&
110+
git --git-dir=pushee -c transfer.hideRefs="^refs/namespaces/namespace/refs/tags" \
111+
ls-remote "ext::git %s pushee" >actual &&
112112
printf "$commit1\trefs/heads/main\n" >expected &&
113113
test_cmp expected actual
114114
'

0 commit comments

Comments
 (0)