summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorMax Kirillov <max@max630.net>2014-11-30 08:24:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-12-01 19:00:19 (GMT)
commitee4fb8435e2186323c6a91d26d1572da12b5d033 (patch)
tree88426fec5af7b2164d0a989e1fa2edeb37f6268e /builtin/checkout.c
parentad35f61518f93cb13ff79d1c85d3e04d03097bf3 (diff)
downloadgit-ee4fb8435e2186323c6a91d26d1572da12b5d033.zip
git-ee4fb8435e2186323c6a91d26d1572da12b5d033.tar.gz
git-ee4fb8435e2186323c6a91d26d1572da12b5d033.tar.bz2
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 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 8c5276c..953b763 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -865,7 +865,7 @@ static int prepare_linked_checkout(const struct checkout_opts *opts,
if (!new->commit)
die(_("no branch specified"));
- if (file_exists(path))
+ if (file_exists(path) && !is_empty_dir(path))
die(_("'%s' already exists"), path);
len = strlen(path);