Skip to content

Commit 914186a

Browse files
committed
Merge branch 'maint-1.6.0' into maint
* maint-1.6.0: fix handling of multiple untracked files for git mv -k add test cases for "git mv -k"
2 parents 8dca683 + be17262 commit 914186a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,31 @@ 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+
'checking -k on non-existing file' \
43+
'git mv -k idontexist path0'
44+
45+
test_expect_success \
46+
'checking -k on untracked file' \
47+
'touch untracked1 &&
48+
git mv -k untracked1 path0 &&
49+
test -f untracked1 &&
50+
test ! -f path0/untracked1'
51+
52+
test_expect_success \
53+
'checking -k on multiple untracked files' \
54+
'touch untracked2 &&
55+
git mv -k untracked1 untracked2 path0 &&
56+
test -f untracked1 &&
57+
test -f untracked2 &&
58+
test ! -f path0/untracked1
59+
test ! -f path0/untracked2'
60+
61+
# clean up the mess in case bad things happen
62+
rm -f idontexist untracked1 untracked2 \
63+
path0/idontexist path0/untracked1 path0/untracked2 \
64+
.git/index.lock
65+
4166
test_expect_success \
4267
'adding another file' \
4368
'cp "$TEST_DIRECTORY"/../README path0/README &&

0 commit comments

Comments
 (0)