Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2006-02-17 10:26:16 +0300
committerJunio C Hamano <junkio@cox.net>2006-02-18 10:52:57 +0300
commit772d8a3b63ff669c285edb8aff0c63b609614933 (patch)
tree9fdefe7143865b57b4ea1231979a21b1cc3dbdba /git-reset.sh
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 '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 fe53fc8065..6cb073cb16 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