From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] attr: don't confuse prefixes with leading directories
Date: Tue, 10 Jan 2012 17:31:04 -0500 [thread overview]
Message-ID: <20120110223104.GA28592@sigill.intra.peff.net> (raw)
In-Reply-To: <7v7h0z9ufu.fsf@alter.siamese.dyndns.org>
On Tue, Jan 10, 2012 at 12:25:09PM -0800, Junio C Hamano wrote:
> Sorry for sending a half-baked response. The initial draft of my response
> had just "that makes sense" and nothing else in the first paragraph.
>
> If the original meant to be defensive, it should have had your "extra
> defensive" die(), but it didn't.
> [...]
> diff --git a/attr.c b/attr.c
> index ad7eb9c..4d3b61a 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -566,7 +567,9 @@ static void prepare_attr_stack(const char *path, int dirlen)
>
> /*
> * Pop the ones from directories that are not the prefix of
> - * the path we are checking.
> + * the path we are checking. Break out of the loop when we see
> + * the root one (whose origin is an empty string "") or the builtin
> + * one (whose origin is NULL) without popping it.
> */
> while (attr_stack->origin) {
> int namelen = strlen(attr_stack->origin);
> @@ -586,6 +589,13 @@ static void prepare_attr_stack(const char *path, int dirlen)
> * Read from parent directories and push them down
> */
> if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {
> + /*
> + * bootstrap_attr_stack() should have added, and the
> + * above loop should have stopped before popping, the
> + * root element whose attr_stack->origin is set to an
> + * empty string.
> + */
> + assert(attr_stack->origin);
> while (1) {
> char *cp;
Yeah, this version looks good to me (though I thought we usually spelled
assert as die("BUG: ...")).
-Peff
next prev parent reply other threads:[~2012-01-10 22:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-10 7:03 [BUG] gitattribute macro expansion oddity Jeff King
2012-01-10 9:01 ` Michael Haggerty
2012-01-10 17:11 ` Jeff King
2012-01-10 18:08 ` [PATCH] attr: don't confuse prefixes with leading directories Jeff King
2012-01-10 18:21 ` Jeff King
2012-01-10 19:23 ` Junio C Hamano
2012-01-10 19:28 ` Jeff King
2012-01-10 19:32 ` Jeff King
2012-01-10 20:25 ` Junio C Hamano
2012-01-10 22:31 ` Jeff King [this message]
2012-01-10 19:25 ` Junio C Hamano
2012-01-10 17:22 ` [BUG] gitattribute macro expansion oddity Junio C Hamano
2012-01-11 4:37 ` Michael Haggerty
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=20120110223104.GA28592@sigill.intra.peff.net \
--to=peff@peff.net \
--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).