path: root/
diff options
authorShawn Pearce <>2006-02-17 07:26:16 (GMT)
committerJunio C Hamano <>2006-02-18 07:52:57 (GMT)
commit772d8a3b63ff669c285edb8aff0c63b609614933 (patch)
tree9fdefe7143865b57b4ea1231979a21b1cc3dbdba /
parent735d80b3bf1be9513d030e61af1ef6512cec015a (diff)
Make git-reset delete empty directories
When git-reset --hard is used and a subdirectory becomes empty (as it contains no tracked files in the target tree) the empty subdirectory should be removed. This matches the behavior of git-checkout-index and git-read-tree -m which would not have created the subdirectory or would have deleted it when updating the working directory. Subdirectories which are not empty will be left behind. This may happen if the subdirectory still contains object files from the user's build process (for example). [jc: simplified the logic a bit, while keeping the test script.]
Diffstat (limited to '')
1 files changed, 3 insertions, 0 deletions
diff --git a/ b/
index fe53fc8..6cb073c 100755
--- a/
+++ b/
@@ -88,6 +88,9 @@ case "$reset_type" in
# it is ok if this fails -- it may already
# have been culled by checkout-index.
unlink $_;
+ while (s|/[^/]*$||) {
+ rmdir($_) or last;
+ }
' $tmp-exists