Skip to content

Commit c9bc2c5

Browse files
committed
Merge branch 'sm/mv-dry-run-update' into maint
Code clean-up. * sm/mv-dry-run-update: mv: remove unneeded 'if (!show_only)' t7001: add test case for --dry-run
2 parents 342215b + 4cbe92f commit c9bc2c5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

builtin/mv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
286286

287287
pos = cache_name_pos(src, strlen(src));
288288
assert(pos >= 0);
289-
if (!show_only)
290-
rename_cache_entry_at(pos, dst);
289+
rename_cache_entry_at(pos, dst);
291290
}
292291

293292
if (gitmodules_modified)

t/t7001-mv.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ test_expect_success \
3838
'git diff-tree -r -M --name-status HEAD^ HEAD | \
3939
grep "^R100..*path1/COPYING..*path0/COPYING"'
4040

41+
test_expect_success \
42+
'mv --dry-run does not move file' \
43+
'git mv -n path0/COPYING MOVED &&
44+
test -f path0/COPYING &&
45+
test ! -f MOVED'
46+
4147
test_expect_success \
4248
'checking -k on non-existing file' \
4349
'git mv -k idontexist path0'

0 commit comments

Comments
 (0)