From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] fetch: use skip_prefix() instead of starts_with()
Date: Tue, 26 Nov 2019 11:09:34 -0500 [thread overview]
Message-ID: <20191126160934.GD25729@sigill.intra.peff.net> (raw)
In-Reply-To: <f6ed729b-3cd3-a91a-d69d-4960e4a0524f@web.de>
On Tue, Nov 26, 2019 at 12:18:26PM +0100, René Scharfe wrote:
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 863c858fde..02e8619618 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -954,18 +954,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
> kind = "";
> what = "";
> }
> - else if (starts_with(rm->name, "refs/heads/")) {
> + else if (skip_prefix(rm->name, "refs/heads/", &what))
> kind = "branch";
> - what = rm->name + 11;
> - }
> - else if (starts_with(rm->name, "refs/tags/")) {
> + else if (skip_prefix(rm->name, "refs/tags/", &what))
> kind = "tag";
> - what = rm->name + 10;
> - }
> - else if (starts_with(rm->name, "refs/remotes/")) {
> + else if (skip_prefix(rm->name, "refs/remotes/", &what))
> kind = "remote-tracking branch";
> - what = rm->name + 13;
> - }
> else {
Yep, this one looks obviously correct. We were already mutating "what",
so this just does it inside skip_prefix(). Much nicer.
-Peff
prev parent reply other threads:[~2019-11-26 16:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 11:18 [PATCH] fetch: use skip_prefix() instead of starts_with() René Scharfe
2019-11-26 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191126160934.GD25729@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.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.
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).