summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f01f109)
raw | patch | inline | side by side (parent: f01f109)
author | Jeff King <peff@peff.net> | |
Fri, 19 Feb 2010 05:57:21 +0000 (00:57 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 19 Feb 2010 06:22:22 +0000 (22:22 -0800) |
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: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c | patch | blob | history | |
t/t3600-rm.sh | patch | blob | history |
index 6aae09a22e54a7b9291ed1b6acf79529c6029a49..fdc0a2ede1b679d31570edd6f6334b7f29800c06 100644 (file)
--- a/dir.c
+++ b/dir.c
slash = dirs + (slash - name);
do {
*slash = '\0';
- } while (rmdir(dirs) && (slash = strrchr(dirs, '/')));
+ } while (rmdir(dirs) == 0 && (slash = strrchr(dirs, '/')));
free(dirs);
}
return 0;
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 76b1bb45456a18a8c1c33256695396cc2b65a3a9..0aaf0ad84b05e1ee17e9789811ea06f2d2798556 100755 (executable)
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
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