From: Greg Price <price@ksplice.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] pack-refs: remove newly empty directories
Date: Mon, 5 Jul 2010 23:25:36 -0400 [thread overview]
Message-ID: <AANLkTilDcpdekvsw9b4TN8QNpubs6wkpibXdzz2AkTf-@mail.gmail.com> (raw)
In-Reply-To: <7vsk3x5n35.fsf@alter.siamese.dyndns.org>
On Mon, Jul 5, 2010 at 11:02 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Will this keep refs/heads/p/q that is empty after packing p/q/r/s branch
> that happens to be the only branch whose name begins with p/?
>
> I do not want a careless loop that will remove refs/heads after packing
> "master" that happens to be the only local branch, but still...
It will. I could fix that with something like this (untested):
/* Remove empty parents, but spare refs/ and immediate subdirs.
Note, munges *name. */
static void try_remove_empty_parents(char *name)
{
char *p, *q;
int i;
p = name;
for (i = 0; i < 2; i++) { /* refs/{heads,tags,...}/ */
while (*p && *p != '/')
p++;
if (*p)
p++;
}
for (q = p; *q; q++)
;
while (1) {
for ( ; q > p && *q != '/'; q--)
;
if (q == p)
break;
*q = '\0';
if (rmdir(git_path("%s", name)))
break;
}
}
and then
if (lock) {
unlink_or_warn(git_path("%s", r->name));
unlock_ref(lock);
+ try_remove_empty_parents(r->name);
}
Sound reasonable?
Greg
next prev parent reply other threads:[~2010-07-06 3:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-05 22:27 [PATCH] pack-refs: remove newly empty directories Greg Price
2010-07-06 3:02 ` Junio C Hamano
2010-07-06 3:25 ` Greg Price [this message]
2010-07-06 23:29 ` [PATCH v2] " Greg Price
2010-07-06 6:10 ` [PATCH] " Johannes Sixt
2010-07-06 6:15 ` Junio C Hamano
2010-07-06 18:49 ` Andreas Schwab
2010-07-06 19:13 ` Greg Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTilDcpdekvsw9b4TN8QNpubs6wkpibXdzz2AkTf-@mail.gmail.com \
--to=price@ksplice.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).