From: Junio C Hamano Date: Tue, 6 Mar 2018 22:54:00 +0000 (-0800) Subject: Merge branch 'sm/mv-dry-run-update' X-Git-Tag: v2.17.0-rc0~49 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a4ae2e5a1c45890f5eeccb2d1989a15c07f99e3d?hp=05d290e1dbd2ed424cd3c872c5b20390100fa5f7 Merge branch 'sm/mv-dry-run-update' Code clean-up. * sm/mv-dry-run-update: mv: remove unneeded 'if (!show_only)' t7001: add test case for --dry-run --- diff --git a/builtin/mv.c b/builtin/mv.c index cf3684d907..8ce6a2ddd4 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -286,8 +286,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) pos = cache_name_pos(src, strlen(src)); assert(pos >= 0); - if (!show_only) - rename_cache_entry_at(pos, dst); + rename_cache_entry_at(pos, dst); } if (gitmodules_modified) diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 6e5031f56f..d4e6485a26 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -38,6 +38,12 @@ test_expect_success \ 'git diff-tree -r -M --name-status HEAD^ HEAD | \ grep "^R100..*path1/COPYING..*path0/COPYING"' +test_expect_success \ + 'mv --dry-run does not move file' \ + 'git mv -n path0/COPYING MOVED && + test -f path0/COPYING && + test ! -f MOVED' + test_expect_success \ 'checking -k on non-existing file' \ 'git mv -k idontexist path0'