From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH v2] wt-status: correct and simplify check for detached HEAD
Date: Sat, 28 Nov 2015 12:31:31 -0500 [thread overview]
Message-ID: <20151128173131.GF27264@sigill.intra.peff.net> (raw)
In-Reply-To: <5655C14A.1060308@web.de>
On Wed, Nov 25, 2015 at 03:10:18PM +0100, René Scharfe wrote:
> Fix that by doing the comparison using strcmp() and only after the
> branch name is extracted. This way neither too less nor too many
> characters are checked. While at it call strchrnul() to find the end
> of the branch name instead of open-coding it.
>
> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> We can be more careful when parsing -- or avoid parsing and backtrack
> if we found "HEAD" after all. The latter is simpler, and string
> parsing is tricky enough that we better take such opportunities to
> simplify the code..
Yeah, I think this is nicer. We end up allocating either way anyway, so
the only extra effort is copy the string.
-Peff
prev parent reply other threads:[~2015-11-28 17:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-06 22:47 [PATCH] wt-status: use strncmp() for length-limited string comparison René Scharfe
2015-11-24 21:36 ` Jeff King
2015-11-25 2:16 ` René Scharfe
2015-11-25 9:15 ` Jeff King
2015-11-25 10:29 ` Matthieu Moy
2015-11-25 14:10 ` [PATCH v2] wt-status: correct and simplify check for detached HEAD René Scharfe
2015-11-25 16:21 ` Matthieu Moy
2015-11-28 17:31 ` 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=20151128173131.GF27264@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=pclouds@gmail.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.
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).