Merge branch 'maint'
[gitweb.git] / t / t2026-prune-linked-checkouts.sh
index 2936d52a9c7f860ea9fe3c195b18e9891fc5908f..1821a480c5ce6fd31416201e3a3dcb0f17b1de91 100755 (executable)
@@ -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
@@ -65,7 +69,7 @@ test_expect_success 'prune directories with gitdir pointing to nowhere' '
 '
 
 test_expect_success 'not prune locked checkout' '
-       test_when_finished rm -r .git/worktrees
+       test_when_finished rm -r .git/worktrees &&
        mkdir -p .git/worktrees/ghi &&
        : >.git/worktrees/ghi/locked &&
        git prune --worktrees &&
@@ -73,12 +77,20 @@ test_expect_success 'not prune locked checkout' '
 '
 
 test_expect_success 'not prune recent checkouts' '
-       test_when_finished rm -r .git/worktrees
+       test_when_finished rm -r .git/worktrees &&
        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