summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorMax Kirillov <max@max630.net>2015-03-30 20:47:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-31 18:02:11 (GMT)
commit562bc080934b1bd16099723e80cc82a0dc6356b7 (patch)
tree8ba6b41358d89bf301ad9c6782088be7a0440024 /t
parent466e8d5d660ba732c1065ab3329c91e4b4aa7739 (diff)
downloadgit-562bc080934b1bd16099723e80cc82a0dc6356b7.zip
git-562bc080934b1bd16099723e80cc82a0dc6356b7.tar.gz
git-562bc080934b1bd16099723e80cc82a0dc6356b7.tar.bz2
prune --worktrees: fix expire vs worktree existence condition
`git prune --worktrees` was pruning worktrees which were non-existent OR expired, while it rather should prune those which are orphaned AND expired, as git-checkout documentation describes. Fix it. Add test 'not prune proper checkouts', which uses valid but expired worktree. Modify test 'not prune recent checkouts' to remove the worktree before pruning - link in worktrees still must survive. In older form it is useless because would pass always when the other test passes. Signed-off-by: Max Kirillov <max@max630.net> Acked-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t2026-prune-linked-checkouts.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/t2026-prune-linked-checkouts.sh b/t/t2026-prune-linked-checkouts.sh
index e885baf..1821a48 100755
--- a/t/t2026-prune-linked-checkouts.sh
+++ b/t/t2026-prune-linked-checkouts.sh
@@ -4,6 +4,10 @@ test_description='prune $GIT_DIR/worktrees'
. ./test-lib.sh
+test_expect_success initialize '
+ git commit --allow-empty -m init
+'
+
test_expect_success 'prune --worktrees on normal repo' '
git prune --worktrees &&
test_must_fail git prune --worktrees abc
@@ -77,8 +81,16 @@ test_expect_success 'not prune recent checkouts' '
mkdir zz &&
mkdir -p .git/worktrees/jlm &&
echo "$(pwd)"/zz >.git/worktrees/jlm/gitdir &&
+ rmdir zz &&
git prune --worktrees --verbose --expire=2.days.ago &&
test -d .git/worktrees/jlm
'
+test_expect_success 'not prune proper checkouts' '
+ test_when_finished rm -r .git/worktrees &&
+ git checkout "--to=$PWD/nop" --detach master &&
+ git prune --worktrees &&
+ test -d .git/worktrees/nop
+'
+
test_done