Re: [PATCH] Make git-reset delete empty directories
- From
Junio C Hamano <junkio@cox.net>
- Date
- Feb 17, 2006, 08:15 UTC
- Message-ID
- <7v7j7u8koz.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <20060217072616.GA15358@spearce.org>
Shawn Pearce <spearce@spearce.org> writes:
> 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.
I thought I said it would be a few-liner, but it appears I did not send that message.
This untested one is far simpler, if less efficient, isn't it?
---
diff --git a/git-reset.sh b/git-reset.sh index fe53fc8..195d043 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|/[^/]*$|| && $_ ne "") { + rmdir($_) or last; + } } } ' $tmp-exists