Re: [PATCH v2] wt-status: correct and simplify check for detached HEAD

2015-11-28 Thread Jeff King
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 instea

Re: [PATCH v2] wt-status: correct and simplify check for detached HEAD

2015-11-25 Thread Matthieu Moy
René Scharfe writes: > diff --git a/wt-status.c b/wt-status.c > index 435fc28..ced53dd 100644 > --- a/wt-status.c > +++ b/wt-status.c > @@ -1317,15 +1317,14 @@ static int grab_1st_switch(unsigned char *osha1, > unsigned char *nsha1, > target += strlen(" to "); > strbuf_reset(&cb->buf

[PATCH v2] wt-status: correct and simplify check for detached HEAD

2015-11-25 Thread René Scharfe
If a branch name is longer than four characters then memcmp() reads over the end of the static string "HEAD". This causes the following test failures with AddressSanitizer: t3203-branch-output.sh (Wstat: 256 Tests: 18 Failed: 4) Failed tests: 12, 15-17 Non-zero exi