interpret_branch_name(): handle auto-namelen for @{-1}
commit13228c30a6476456ee64eb7cefb7786d82fd2ca7
authorJeff King <peff@peff.net>
Mon, 27 Feb 2017 09:25:40 +0000 (27 04:25 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Mar 2017 19:04:57 +0000 (2 11:04 -0800)
treec829818e460604eb58cce62a44e38265b693db0e
parent3b9e3c2cede15057af3ff8076c45ad5f33829436
interpret_branch_name(): handle auto-namelen for @{-1}

The interpret_branch_name() function takes a ptr/len pair
for the name, but you can pass "0" for "namelen", which will
cause it to check the length with strlen().

However, before we do that auto-namelen magic, we call
interpret_nth_prior_checkout(), which gets fed the bogus
"0". This was broken by 8cd4249c4 (interpret_branch_name:
always respect "namelen" parameter, 2014-01-15).  Though to
be fair to that commit, it was broken in the _opposite_
direction before, where we would always treat "name" as a
string even if a length was passed.

You can see the bug with "git log -g @{-1}". That code path
always passes "0", and without this patch it cannot figure
out which branch's reflog to show.

We can fix it by a small reordering of the code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
t/t0100-previous.sh