Skip to content

Commit 5de8a54

Browse files
rappazzogitster
authored andcommitted
rev-parse tests: add tests executed from a subdirectory
t2027-worktree-list has an incorrect expectation for --git-common-dir which has been adjusted and marked to expect failure. Some of the tests added have been marked to expect failure. These demonstrate a problem with the way that some options to git rev-parse behave when executed from a subdirectory of the main worktree. [jes: fixed incorrect assumption that objects/ lives in the worktree-specific git-dir (it lives in the common dir instead). Also adjusted t1700 so that the test case does not *need* to be the last one in that script.] Signed-off-by: Michael Rappazzo <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6e3a7b3 commit 5de8a54

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

t/t1500-rev-parse.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,32 @@ test_rev_parse -C work -g ../repo.git -b t 'GIT_DIR=../repo.git, core.bare = tru
8787

8888
test_rev_parse -C work -g ../repo.git -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
8989

90+
test_expect_success 'git-common-dir from worktree root' '
91+
echo .git >expect &&
92+
git rev-parse --git-common-dir >actual &&
93+
test_cmp expect actual
94+
'
95+
96+
test_expect_failure 'git-common-dir inside sub-dir' '
97+
mkdir -p path/to/child &&
98+
test_when_finished "rm -rf path" &&
99+
echo "$(git -C path/to/child rev-parse --show-cdup).git" >expect &&
100+
git -C path/to/child rev-parse --git-common-dir >actual &&
101+
test_cmp expect actual
102+
'
103+
104+
test_expect_success 'git-path from worktree root' '
105+
echo .git/objects >expect &&
106+
git rev-parse --git-path objects >actual &&
107+
test_cmp expect actual
108+
'
109+
110+
test_expect_failure 'git-path inside sub-dir' '
111+
mkdir -p path/to/child &&
112+
test_when_finished "rm -rf path" &&
113+
echo "$(git -C path/to/child rev-parse --show-cdup).git/objects" >expect &&
114+
git -C path/to/child rev-parse --git-path objects >actual &&
115+
test_cmp expect actual
116+
'
117+
90118
test_done

t/t1700-split-index.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,20 @@ EOF
200200
test_cmp expect actual
201201
'
202202

203+
test_expect_failure 'rev-parse --shared-index-path' '
204+
test_create_repo split-index &&
205+
(
206+
cd split-index &&
207+
git update-index --split-index &&
208+
echo .git/sharedindex* >expect &&
209+
git rev-parse --shared-index-path >actual &&
210+
test_cmp expect actual &&
211+
mkdir subdirectory &&
212+
cd subdirectory &&
213+
echo ../.git/sharedindex* >expect &&
214+
git rev-parse --shared-index-path >actual &&
215+
test_cmp expect actual
216+
)
217+
'
218+
203219
test_done

t/t2027-worktree-list.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@ test_expect_success 'setup' '
88
test_commit init
99
'
1010

11-
test_expect_success 'rev-parse --git-common-dir on main worktree' '
11+
test_expect_failure 'rev-parse --git-common-dir on main worktree' '
1212
git rev-parse --git-common-dir >actual &&
1313
echo .git >expected &&
1414
test_cmp expected actual &&
1515
mkdir sub &&
1616
git -C sub rev-parse --git-common-dir >actual2 &&
17-
echo sub/.git >expected2 &&
17+
echo ../.git >expected2 &&
1818
test_cmp expected2 actual2
1919
'
2020

21+
test_expect_failure 'rev-parse --git-path objects linked worktree' '
22+
echo "$(git rev-parse --show-toplevel)/.git/objects" >expect &&
23+
test_when_finished "rm -rf linked-tree && git worktree prune" &&
24+
git worktree add --detach linked-tree master &&
25+
git -C linked-tree rev-parse --git-path objects >actual &&
26+
test_cmp expect actual
27+
'
28+
2129
test_expect_success '"list" all worktrees from main' '
2230
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
2331
test_when_finished "rm -rf here && git worktree prune" &&

0 commit comments

Comments
 (0)