summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8ba6b1)
raw | patch | inline | side by side (parent: c8ba6b1)
author | Matthieu Moy <Matthieu.Moy@imag.fr> | |
Wed, 4 Feb 2009 09:32:08 +0000 (10:32 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 4 Feb 2009 19:07:42 +0000 (11:07 -0800) |
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>
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>
builtin-mv.c | patch | blob | history | |
t/t7001-mv.sh | patch | blob | history |
diff --git a/builtin-mv.c b/builtin-mv.c
index bce9959293e30925c4b16c40ac33a3f2e0474e30..01270fefdfb04ed27379b1ca761a811b929ce887 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
}
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) {
/*
} 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);
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index ef7e56ed6307ba351caaa38d92e0be04a3f920bc..d2ec550af6c749ed6f41c89ca9f4c238e227034d 100755 (executable)
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
test ! -f path0/untracked1 &&
test ! -f path0/untracked2'
-test_expect_failure \
+test_expect_success \
'checking -f on untracked file with existing target' \
'touch path0/untracked1 &&
git mv -f untracked1 path0