Skip to content

Commit be17262

Browse files
Michael J Grubergitster
authored andcommitted
fix handling of multiple untracked files for git mv -k
The "-k" option to "git mv" should allow specifying multiple untracked files. Currently, multiple untracked files raise an assertion if they appear consecutively as arguments. Fix this by decrementing the loop index after removing one entry from the array of arguments. Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3772923 commit be17262

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

builtin-mv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
192192
memmove(destination + i,
193193
destination + i + 1,
194194
(argc - i) * sizeof(char *));
195+
i--;
195196
}
196197
} else
197198
die ("%s, source=%s, destination=%s",

t/t7001-mv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_expect_success \
4949
test -f untracked1 &&
5050
test ! -f path0/untracked1'
5151

52-
test_expect_failure \
52+
test_expect_success \
5353
'checking -k on multiple untracked files' \
5454
'touch untracked2 &&
5555
git mv -k untracked1 untracked2 path0 &&

0 commit comments

Comments
 (0)