@@ -7,13 +7,26 @@ TEST_PASSES_SANITIZE_LEAK=true
7
7
8
8
pwd=" $( pwd) "
9
9
10
- expect_accepted () {
11
- git " $@ " rev-parse --git-dir
10
+ expect_accepted_implicit () {
11
+ test_when_finished ' rm "$pwd/trace.perf"' &&
12
+ GIT_TRACE2_PERF=" $pwd /trace.perf" git " $@ " rev-parse --git-dir &&
13
+ # Note: we're intentionally only checking that the bare repo has a
14
+ # directory *prefix* of $pwd
15
+ grep -F " implicit-bare-repository:$pwd " " $pwd /trace.perf"
16
+ }
17
+
18
+ expect_accepted_explicit () {
19
+ test_when_finished ' rm "$pwd/trace.perf"' &&
20
+ GIT_DIR=" $1 " GIT_TRACE2_PERF=" $pwd /trace.perf" git rev-parse --git-dir &&
21
+ ! grep -F " implicit-bare-repository:$pwd " " $pwd /trace.perf"
12
22
}
13
23
14
24
expect_rejected () {
15
- test_must_fail git " $@ " rev-parse --git-dir 2> err &&
16
- grep -F " cannot use bare repository" err
25
+ test_when_finished ' rm "$pwd/trace.perf"' &&
26
+ test_env GIT_TRACE2_PERF=" $pwd /trace.perf" \
27
+ test_must_fail git " $@ " rev-parse --git-dir 2> err &&
28
+ grep -F " cannot use bare repository" err &&
29
+ grep -F " implicit-bare-repository:$pwd " " $pwd /trace.perf"
17
30
}
18
31
19
32
test_expect_success ' setup bare repo in worktree' '
@@ -22,12 +35,13 @@ test_expect_success 'setup bare repo in worktree' '
22
35
'
23
36
24
37
test_expect_success ' safe.bareRepository unset' '
25
- expect_accepted -C outer-repo/bare-repo
38
+ test_unconfig --global safe.bareRepository &&
39
+ expect_accepted_implicit -C outer-repo/bare-repo
26
40
'
27
41
28
42
test_expect_success ' safe.bareRepository=all' '
29
43
test_config_global safe.bareRepository all &&
30
- expect_accepted -C outer-repo/bare-repo
44
+ expect_accepted_implicit -C outer-repo/bare-repo
31
45
'
32
46
33
47
test_expect_success ' safe.bareRepository=explicit' '
@@ -47,7 +61,7 @@ test_expect_success 'safe.bareRepository in the repository' '
47
61
48
62
test_expect_success ' safe.bareRepository on the command line' '
49
63
test_config_global safe.bareRepository explicit &&
50
- expect_accepted -C outer-repo/bare-repo \
64
+ expect_accepted_implicit -C outer-repo/bare-repo \
51
65
-c safe.bareRepository=all
52
66
'
53
67
@@ -60,4 +74,8 @@ test_expect_success 'safe.bareRepository in included file' '
60
74
expect_rejected -C outer-repo/bare-repo
61
75
'
62
76
77
+ test_expect_success ' no trace when GIT_DIR is explicitly provided' '
78
+ expect_accepted_explicit "$pwd/outer-repo/bare-repo"
79
+ '
80
+
63
81
test_done
0 commit comments