summaryrefslogtreecommitdiff
path: root/builtin-mv.c
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2009-02-04 10:32:08 +0100
committerJunio C Hamano <gitster@pobox.com>2009-02-04 11:07:42 -0800
commit5aed3c6ab834367292bd7a9b0894177a07afd910 (patch)
tree4be58af9c9128aa8f1ff36e07f55857559c1456b /builtin-mv.c
parentc8ba6b1b199bf00f227e8fdad4adb5a2147c8160 (diff)
downloadgit-5aed3c6ab834367292bd7a9b0894177a07afd910.tar.gz
builtin-mv.c: check for unversionned files before looking at the destination.
The previous code was failing in the case where one moves an unversionned file to an existing destination, with mv -f: the "existing destination" was checked first, and the error was cancelled by the force flag. We now check the unrecoverable error first, which fixes the bug. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-mv.c')
-rw-r--r--builtin-mv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin-mv.c b/builtin-mv.c
index bce9959293..01270fefdf 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -162,7 +162,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
}
argc += last - first;
}
- } else if (lstat(dst, &st) == 0) {
+ } else if (cache_name_pos(src, length) < 0)
+ bad = "not under version control";
+ else if (lstat(dst, &st) == 0) {
bad = "destination exists";
if (force) {
/*
@@ -177,9 +179,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
} else
bad = "Cannot overwrite";
}
- } else if (cache_name_pos(src, length) < 0)
- bad = "not under version control";
- else if (string_list_has_string(&src_for_dst, dst))
+ } else if (string_list_has_string(&src_for_dst, dst))
bad = "multiple sources for the same target";
else
string_list_insert(dst, &src_for_dst);