提交 3fc0d131 编写于 作者: J Jeff King 提交者: Junio C Hamano

rm: fix bug in recursive subdirectory removal

If we remove a path in a/deep/subdirectory, we should try to
remove as many trailing components as possible (i.e.,
subdirectory, then deep, then a). However, the test for the
return value of rmdir was reversed, so we only ever deleted
at most one level.

The fix is in remove_path, so "apply" and "merge-recursive"
also are fixed.
Signed-off-by: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 f01f1099
......@@ -864,7 +864,7 @@ int remove_path(const char *name)
slash = dirs + (slash - name);
do {
*slash = '\0';
} while (rmdir(dirs) && (slash = strrchr(dirs, '/')));
} while (rmdir(dirs) == 0 && (slash = strrchr(dirs, '/')));
free(dirs);
}
return 0;
......
......@@ -271,4 +271,12 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
test "$status" != 0
'
test_expect_success 'rm removes subdirectories recursively' '
mkdir -p dir/subdir/subsubdir &&
echo content >dir/subdir/subsubdir/file &&
git add dir/subdir/subsubdir/file &&
git rm -f dir/subdir/subsubdir/file &&
! test -d dir
'
test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册