From c5203bdf66531c848a2b6cd74f3c02cb18286c55 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 18 Aug 2006 12:42:39 +0200 Subject: [PATCH] git-mv: special case destination "." Since the normalized basename of "." is "", the check for directory failed erroneously. Noticed by Fredrik Kuivinen. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-mv.c | 5 ++++- t/t7001-mv.sh | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin-mv.c b/builtin-mv.c index c0c8764f7..b2ecc26f2 100644 --- a/builtin-mv.c +++ b/builtin-mv.c @@ -114,7 +114,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix) modes = xcalloc(count, sizeof(enum update_mode)); dest_path = copy_pathspec(prefix, argv + argc - 1, 1, 0); - if (!lstat(dest_path[0], &st) && + if (dest_path[0][0] == '\0') + /* special case: "." was normalized to "" */ + destination = copy_pathspec(dest_path[0], argv + i, count, 1); + else if (!lstat(dest_path[0], &st) && S_ISDIR(st.st_mode)) { dest_path[0] = add_slash(dest_path[0]); destination = copy_pathspec(dest_path[0], argv + i, count, 1); diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index e5e0bb9d5..b7fcdb390 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -82,4 +82,8 @@ test_expect_failure \ 'do not move directory over existing directory' \ 'mkdir path0 && mkdir path0/path2 && git-mv path2 path0' +test_expect_success \ + 'move into "."' \ + 'git-mv path1/path2/ .' + test_done -- 2.30.2