Merge branch 'rs/status-detached-head-memcmp' into maint
Fix some string-matching corner cases when digging in the reflog for "git status". * rs/status-detached-head-memcmp: wt-status: correct and simplify check for detached HEAD
This commit is contained in:
@ -1317,15 +1317,14 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
|
|||||||
target += strlen(" to ");
|
target += strlen(" to ");
|
||||||
strbuf_reset(&cb->buf);
|
strbuf_reset(&cb->buf);
|
||||||
hashcpy(cb->nsha1, nsha1);
|
hashcpy(cb->nsha1, nsha1);
|
||||||
for (end = target; *end && *end != '\n'; end++)
|
end = strchrnul(target, '\n');
|
||||||
;
|
strbuf_add(&cb->buf, target, end - target);
|
||||||
if (!memcmp(target, "HEAD", end - target)) {
|
if (!strcmp(cb->buf.buf, "HEAD")) {
|
||||||
/* HEAD is relative. Resolve it to the right reflog entry. */
|
/* HEAD is relative. Resolve it to the right reflog entry. */
|
||||||
|
strbuf_reset(&cb->buf);
|
||||||
strbuf_addstr(&cb->buf,
|
strbuf_addstr(&cb->buf,
|
||||||
find_unique_abbrev(nsha1, DEFAULT_ABBREV));
|
find_unique_abbrev(nsha1, DEFAULT_ABBREV));
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
strbuf_add(&cb->buf, target, end - target);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user