Skip to content

Commit

Permalink
Merge branch 'jk/maint-rmdir-fix' into maint
Browse files Browse the repository at this point in the history
* jk/maint-rmdir-fix:
  rm: fix bug in recursive subdirectory removal
  • Loading branch information
Junio C Hamano committed Feb 19, 2010
2 parents 738820a + 3fc0d13 commit 7c0be4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions t/t3600-rm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7c0be4d

Please sign in to comment.