summaryrefslogtreecommitdiff
path: root/t/t2027-worktree-list.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-02-12 04:31:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-13 00:01:47 (GMT)
commit17f1365dbce9aa00cab3f196e7fa7138d9081eef (patch)
tree8d66e92d668049ec01b4d970d8fcc0506e0b1b99 /t/t2027-worktree-list.sh
parent754884255bb580df159e58defa81cdd30b5c430c (diff)
downloadgit-17f1365dbce9aa00cab3f196e7fa7138d9081eef.zip
git-17f1365dbce9aa00cab3f196e7fa7138d9081eef.tar.gz
git-17f1365dbce9aa00cab3f196e7fa7138d9081eef.tar.bz2
rev-parse: take prefix into account in --git-common-dir
Most of the time, get_git_common_dir() returns an absolute path so prefix is irrelevant. If it returns a relative path (e.g. from the main worktree) then prefixing is required. Noticed-by: Mike Hommey <mh@glandium.org> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2027-worktree-list.sh')
-rwxr-xr-xt/t2027-worktree-list.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t2027-worktree-list.sh b/t/t2027-worktree-list.sh
index 75ebb1b..1b1b65a 100755
--- a/t/t2027-worktree-list.sh
+++ b/t/t2027-worktree-list.sh
@@ -8,6 +8,16 @@ test_expect_success 'setup' '
test_commit init
'
+test_expect_success 'rev-parse --git-common-dir on main worktree' '
+ git rev-parse --git-common-dir >actual &&
+ echo .git >expected &&
+ test_cmp expected actual &&
+ mkdir sub &&
+ git -C sub rev-parse --git-common-dir >actual2 &&
+ echo sub/.git >expected2 &&
+ test_cmp expected2 actual2
+'
+
test_expect_success '"list" all worktrees from main' '
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
test_when_finished "rm -rf here && git worktree prune" &&