aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-02-19 01:31:37 -0800
committerJunio C Hamano <gitster@pobox.com>2010-02-19 01:31:37 -0800
commit7c0be4da5cab4efd89ee6583f7009d648a75a725 (patch)
tree7bfea83cf2468f66a8f0ab4aa53f92cc75c241ae
parent738820a913d05427b6c86d227aafd2bac7cd38d1 (diff)
parent3fc0d131c573f6f774e2e4abba9cbda694b08321 (diff)
downloadgit-7c0be4da5cab4efd89ee6583f7009d648a75a725.tar.gz
git-7c0be4da5cab4efd89ee6583f7009d648a75a725.tar.xz
Merge branch 'jk/maint-rmdir-fix' into maint
* jk/maint-rmdir-fix: rm: fix bug in recursive subdirectory removal
-rw-r--r--dir.c2
-rwxr-xr-xt/t3600-rm.sh8
2 files changed, 9 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 67c3af6a1..133c333df 100644
--- a/dir.c
+++ b/dir.c
@@ -1044,7 +1044,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;
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 76b1bb454..0aaf0ad84 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -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