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 <rappazzo@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Rappazzo committed
Feb 17, 2017 at 17:59 UTC
5de8a549b4e7cdaccfd343bf5b0a0dc18becec32
3 files changed
+54
-2
t/t1500-rev-parse.sh
+28
@@ -87,4 +87,32 @@ test_rev_parse -C work -g ../repo.git -b t 'GIT_DIR=../repo.git, core.bare = tru
87
88
test_rev_parse -C work -g ../repo.git -b u 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
89
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
+
118
test_done
t/t1700-split-index.sh
+16
@@ -200,4 +200,20 @@ EOF
200
test_cmp expect actual
201
'
202
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
+
219
test_done
t/t2027-worktree-list.sh
+10
-2
@@ -8,16 +8,24 @@ test_expect_success 'setup' '
8
test_commit init
9
'
10
11
-test_expect_success 'rev-parse --git-common-dir on main worktree' '
11
+test_expect_failure 'rev-parse --git-common-dir on main worktree' '
12
git rev-parse --git-common-dir >actual &&
13
echo .git >expected &&
14
test_cmp expected actual &&
15
mkdir sub &&
16
git -C sub rev-parse --git-common-dir >actual2 &&
17
- echo sub/.git >expected2 &&
17
+ echo ../.git >expected2 &&
18
test_cmp expected2 actual2
19
'
20
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
+
29
test_expect_success '"list" all worktrees from main' '
30
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
31
test_when_finished "rm -rf here && git worktree prune" &&