From: Shawn Pearce Date: Fri, 17 Feb 2006 15:16:54 GMT Subject: Re: [PATCH] Make git-reset delete empty directories Message-ID: <20060217151654.GA26362@spearce.org> In-Reply-To: <7v7j7u8koz.fsf@assigned-by-dhcp.cox.net> Junio C Hamano wrote: > I thought I said it would be a few-liner, but it appears I did > not send that message. You did. Somehow I forgot that request. I wrote a simple approach similar to what you show below then tried to make it slightly more efficient by only attempting to delete each directory once. Obviously that wasn't wise on my part. :-) > 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 I just ran it through the test script (t7101-reset.sh) that I included in my patch and it passed, so clearly the version above would be the better version to include. Since it was untested before you are welcome to include the test script with your version. :-) -- Shawn.