aboutsummaryrefslogtreecommitdiff
path: root/git-reset.sh
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2006-02-17 02:26:16 -0500
committerJunio C Hamano <junkio@cox.net>2006-02-17 23:52:57 -0800
commit772d8a3b63ff669c285edb8aff0c63b609614933 (patch)
tree9fdefe7143865b57b4ea1231979a21b1cc3dbdba /git-reset.sh
parent735d80b3bf1be9513d030e61af1ef6512cec015a (diff)
downloadgit-772d8a3b63ff669c285edb8aff0c63b609614933.tar.gz
git-772d8a3b63ff669c285edb8aff0c63b609614933.tar.xz
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 'git-reset.sh')
-rwxr-xr-xgit-reset.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/git-reset.sh b/git-reset.sh
index fe53fc806..6cb073cb1 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -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