Skip to content

Commit

Permalink
git-mv: special case destination "."
Browse files Browse the repository at this point in the history
Since the normalized basename of "." is "", the check for directory
failed erroneously.

Noticed by Fredrik Kuivinen.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Aug 21, 2006
1 parent d78b0f3 commit c5203bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion builtin-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions t/t7001-mv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c5203bd

Please sign in to comment.