From 3fc0d131c573f6f774e2e4abba9cbda694b08321 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 19 Feb 2010 00:57:21 -0500 Subject: 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: Jeff King Signed-off-by: Junio C Hamano --- dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index 6aae09a22e..fdc0a2ede1 100644 --- a/dir.c +++ b/dir.c @@ -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; -- cgit v1.2.3