Merge branch 'maint-1.6.0' into maint

* maint-1.6.0:
  builtin-mv.c: check for unversionned files before looking at the destination.
  Add a testcase for "git mv -f" on untracked files.
  Missing && in t/t7001.sh.
This commit is contained in:
Junio C Hamano 2009-02-04 11:49:07 -08:00
Родитель f081731090 5aed3c6ab8
Коммит 745bc77604
2 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -162,7 +162,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
} }
argc += last - first; argc += last - first;
} }
} else if (lstat(dst, &st) == 0) { } else if (cache_name_pos(src, length) < 0)
bad = "not under version control";
else if (lstat(dst, &st) == 0) {
bad = "destination exists"; bad = "destination exists";
if (force) { if (force) {
/* /*
@ -177,9 +179,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
} else } else
bad = "Cannot overwrite"; bad = "Cannot overwrite";
} }
} else if (cache_name_pos(src, length) < 0) } else if (string_list_has_string(&src_for_dst, dst))
bad = "not under version control";
else if (string_list_has_string(&src_for_dst, dst))
bad = "multiple sources for the same target"; bad = "multiple sources for the same target";
else else
string_list_insert(dst, &src_for_dst); string_list_insert(dst, &src_for_dst);

Просмотреть файл

@ -55,9 +55,17 @@ test_expect_success \
git mv -k untracked1 untracked2 path0 && git mv -k untracked1 untracked2 path0 &&
test -f untracked1 && test -f untracked1 &&
test -f untracked2 && test -f untracked2 &&
test ! -f path0/untracked1 test ! -f path0/untracked1 &&
test ! -f path0/untracked2' test ! -f path0/untracked2'
test_expect_success \
'checking -f on untracked file with existing target' \
'touch path0/untracked1 &&
git mv -f untracked1 path0
test ! -f .git/index.lock &&
test -f untracked1 &&
test -f path0/untracked1'
# clean up the mess in case bad things happen # clean up the mess in case bad things happen
rm -f idontexist untracked1 untracked2 \ rm -f idontexist untracked1 untracked2 \
path0/idontexist path0/untracked1 path0/untracked2 \ path0/idontexist path0/untracked1 path0/untracked2 \