Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2013-12-03 12:32:04 +0400
committerJunio C Hamano <gitster@pobox.com>2013-12-04 23:49:15 +0400
commitc57f6281ff847db7094d708f5c5b939d378f7120 (patch)
tree9081a84d096cf120be9551464cbba2f0c871b777 /t/t7001-mv.sh
parenta155a5f075cdc09e584a58d68bdce0c80e6c4b5a (diff)
mv: let 'git mv file no-such-dir/' error out
Git used to trim the trailing slash, and make the command equivalent to 'git mv file no-such-dir', which created the file no-such-dir (while the trailing slash explicitly stated that it could only be a directory). This patch skips the trailing slash removal for the destination path. The path with its trailing slash is passed to rename(2), which errors out with the appropriate message: $ git mv file no-such-dir/ fatal: renaming 'file' failed: Not a directory Original-patch-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7001-mv.sh')
-rwxr-xr-xt/t7001-mv.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index b90e985a48..3bfdfed1f7 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -70,6 +70,35 @@ test_expect_success \
rm -f idontexist untracked1 untracked2 \
path0/idontexist path0/untracked1 path0/untracked2 \
.git/index.lock
+rmdir path1
+
+test_expect_success \
+ 'moving to absent target with trailing slash' \
+ 'test_must_fail git mv path0/COPYING no-such-dir/ &&
+ test_must_fail git mv path0/COPYING no-such-dir// &&
+ git mv path0/ no-such-dir/ &&
+ test_path_is_dir no-such-dir'
+
+test_expect_success \
+ 'clean up' \
+ 'git reset --hard'
+
+test_expect_success \
+ 'moving to existing untracked target with trailing slash' \
+ 'mkdir path1 &&
+ git mv path0/ path1/ &&
+ test_path_is_dir path1/path0/'
+
+test_expect_success \
+ 'moving to existing tracked target with trailing slash' \
+ 'mkdir path2 &&
+ >path2/file && git add path2/file &&
+ git mv path1/path0/ path2/ &&
+ test_path_is_dir path2/path0/'
+
+test_expect_success \
+ 'clean up' \
+ 'git reset --hard'
test_expect_success \
'adding another file' \