[PATCH v2 8/8] checkout --to: do not touch existing target directory
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/checkout.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 4fbb9c1..3dc416c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -861,6 +861,8 @@ static int prepare_linked_checkout(const struct checkout_opts *opts,
if (!new->commit)
die(_("no branch specified"));
+ if (file_exists(path))
+ die(_("%s already exists"), path);
len = strlen(path);
while (len && is_dir_sep(path[len - 1]))
--
2.1.0.rc0.78.gc0d8480