Re: [PATCH v2] wt-status: correct and simplify check for detached HEAD
- From
Jeff King <peff@peff.net>
- Date
- Nov 28, 2015, 17:31 UTC
- Message-ID
- <20151128173131.GF27264@sigill.intra.peff.net>
- In-Reply-To
- <5655C14A.1060308@web.de>
On Wed, Nov 25, 2015 at 03:10:18PM +0100, René Scharfe wrote:
Show 12 quoted lines
> 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