From: Jeff King Date: Sat, 28 Nov 2015 17:31:31 GMT Subject: Re: [PATCH v2] wt-status: correct and simplify check for detached HEAD 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: > 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 > Signed-off-by: Rene Scharfe > --- > 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