зеркало из https://github.com/microsoft/git.git
Merge branch 'jk/rm-removed-paths'
A handful of test cases and a corner case bugfix for "git rm". * jk/rm-removed-paths: t3600: document failure of rm across symbolic links t3600: test behavior of reverse-d/f conflict rm: do not complain about d/f conflicts during deletion
This commit is contained in:
Коммит
0f3d66c6dc
|
@ -110,7 +110,7 @@ static int check_local_mod(unsigned char *head, int index_only)
|
||||||
ce = active_cache[pos];
|
ce = active_cache[pos];
|
||||||
|
|
||||||
if (lstat(ce->name, &st) < 0) {
|
if (lstat(ce->name, &st) < 0) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT && errno != ENOTDIR)
|
||||||
warning("'%s': %s", ce->name, strerror(errno));
|
warning("'%s': %s", ce->name, strerror(errno));
|
||||||
/* It already vanished from the working tree */
|
/* It already vanished from the working tree */
|
||||||
continue;
|
continue;
|
||||||
|
|
2
dir.c
2
dir.c
|
@ -1647,7 +1647,7 @@ int remove_path(const char *name)
|
||||||
{
|
{
|
||||||
char *slash;
|
char *slash;
|
||||||
|
|
||||||
if (unlink(name) && errno != ENOENT)
|
if (unlink(name) && errno != ENOENT && errno != ENOTDIR)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
slash = strrchr(name, '/');
|
slash = strrchr(name, '/');
|
||||||
|
|
|
@ -622,4 +622,69 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
|
||||||
rm -rf submod
|
rm -rf submod
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rm of d/f when d has become a non-directory' '
|
||||||
|
rm -rf d &&
|
||||||
|
mkdir d &&
|
||||||
|
>d/f &&
|
||||||
|
git add d &&
|
||||||
|
rm -rf d &&
|
||||||
|
>d &&
|
||||||
|
git rm d/f &&
|
||||||
|
test_must_fail git rev-parse --verify :d/f &&
|
||||||
|
test_path_is_file d
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success SYMLINKS 'rm of d/f when d has become a dangling symlink' '
|
||||||
|
rm -rf d &&
|
||||||
|
mkdir d &&
|
||||||
|
>d/f &&
|
||||||
|
git add d &&
|
||||||
|
rm -rf d &&
|
||||||
|
ln -s nonexistent d &&
|
||||||
|
git rm d/f &&
|
||||||
|
test_must_fail git rev-parse --verify :d/f &&
|
||||||
|
test -h d &&
|
||||||
|
test_path_is_missing d
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rm of file when it has become a directory' '
|
||||||
|
rm -rf d &&
|
||||||
|
>d &&
|
||||||
|
git add d &&
|
||||||
|
rm -f d &&
|
||||||
|
mkdir d &&
|
||||||
|
>d/f &&
|
||||||
|
test_must_fail git rm d &&
|
||||||
|
git rev-parse --verify :d &&
|
||||||
|
test_path_is_file d/f
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success SYMLINKS 'rm across a symlinked leading path (no index)' '
|
||||||
|
rm -rf d e &&
|
||||||
|
mkdir e &&
|
||||||
|
echo content >e/f &&
|
||||||
|
ln -s e d &&
|
||||||
|
git add -A e d &&
|
||||||
|
git commit -m "symlink d to e, e/f exists" &&
|
||||||
|
test_must_fail git rm d/f &&
|
||||||
|
git rev-parse --verify :d &&
|
||||||
|
git rev-parse --verify :e/f &&
|
||||||
|
test -h d &&
|
||||||
|
test_path_is_file e/f
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_failure SYMLINKS 'rm across a symlinked leading path (w/ index)' '
|
||||||
|
rm -rf d e &&
|
||||||
|
mkdir d &&
|
||||||
|
echo content >d/f &&
|
||||||
|
git add -A e d &&
|
||||||
|
git commit -m "d/f exists" &&
|
||||||
|
mv d e &&
|
||||||
|
ln -s e d &&
|
||||||
|
test_must_fail git rm d/f &&
|
||||||
|
git rev-parse --verify :d/f &&
|
||||||
|
test -h d &&
|
||||||
|
test_path_is_file e/f
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче