aboutsummaryrefslogtreecommitdiff
path: root/t/t2025-checkout-to.sh
diff options
context:
space:
mode:
authorMax Kirillov <max@max630.net>2014-11-30 15:24:58 +0700
committerJunio C Hamano <gitster@pobox.com>2014-12-01 11:00:19 -0800
commitee4fb8435e2186323c6a91d26d1572da12b5d033 (patch)
tree88426fec5af7b2164d0a989e1fa2edeb37f6268e /t/t2025-checkout-to.sh
parentad35f61518f93cb13ff79d1c85d3e04d03097bf3 (diff)
downloadgit-ee4fb8435e2186323c6a91d26d1572da12b5d033.tar.gz
git-ee4fb8435e2186323c6a91d26d1572da12b5d033.tar.xz
checkout: do not fail if target is an empty directory
Non-recursive checkout creates empty directpries in place of submodules. If then I try to "checkout --to" submodules there, it refuses to do so, because directory already exists. Fix by allowing checking out to empty directory. Add test and modify the existing one so that it uses non-empty directory. Signed-off-by: Max Kirillov <max@max630.net> 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/t2025-checkout-to.sh')
-rwxr-xr-xt/t2025-checkout-to.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/t/t2025-checkout-to.sh b/t/t2025-checkout-to.sh
index eddd3251f..915b506b6 100755
--- a/t/t2025-checkout-to.sh
+++ b/t/t2025-checkout-to.sh
@@ -13,10 +13,15 @@ test_expect_success 'checkout --to not updating paths' '
'
test_expect_success 'checkout --to an existing worktree' '
- mkdir existing &&
+ mkdir -p existing/subtree &&
test_must_fail git checkout --detach --to existing master
'
+test_expect_success 'checkout --to an existing empty worktree' '
+ mkdir existing_empty &&
+ git checkout --detach --to existing_empty master
+'
+
test_expect_success 'checkout --to refuses to checkout locked branch' '
test_must_fail git checkout --to zere master &&
! test -d zere &&