From: Jeff King <peff@peff.net>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Lukas Fleischer <lfleischer@lfos.de>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH v2] refs: use skip_prefix() in ref_is_hidden()
Date: Mon, 24 Jul 2017 12:09:39 -0400 [thread overview]
Message-ID: <20170724160938.bpdqf64p2ja2vvbd@sigill.intra.peff.net> (raw)
In-Reply-To: <20170722043912.32118-1-chriscool@tuxfamily.org>
On Sat, Jul 22, 2017 at 06:39:12AM +0200, Christian Couder wrote:
> @@ -1175,10 +1175,9 @@ int ref_is_hidden(const char *refname, const char *refname_full)
> }
>
> /* refname can be NULL when namespaces are used. */
> - if (!subject || !starts_with(subject, match))
> - continue;
> - len = strlen(match);
> - if (!subject[len] || subject[len] == '/')
> + if (subject &&
> + skip_prefix(subject, match, &p) &&
> + (!*p || *p == '/'))
> return !neg;
This looks good to me.
I seem to recall running across a similar pattern elsewhere, where a
caller wanted either an exact match, or a match ending with a particular
character. We could add one more helper like:
if (subject && skip_prefix_with_sep(subject, match, '/', &p))
return !neg;
But I don't offhand recall where that other place was, and it's not like
it's saving a huge amount of complexity in the caller. So I'll file it
away in the back of my mind and see if it comes up a third time. ;)
-Peff
prev parent reply other threads:[~2017-07-24 16:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-22 4:39 [PATCH v2] refs: use skip_prefix() in ref_is_hidden() Christian Couder
2017-07-24 16:09 ` Jeff King [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170724160938.bpdqf64p2ja2vvbd@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lfleischer@lfos.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).