diff options
author | Jeff King <peff@peff.net> | 2017-02-27 04:25:40 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-02 11:04:57 -0800 |
commit | 13228c30a6476456ee64eb7cefb7786d82fd2ca7 (patch) | |
tree | c829818e460604eb58cce62a44e38265b693db0e /t | |
parent | Git 2.11.1 (diff) | |
download | tgif-13228c30a6476456ee64eb7cefb7786d82fd2ca7.tar.xz |
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>
Diffstat (limited to 't')
-rwxr-xr-x | t/t0100-previous.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh index e0a6940232..58c0b7e9b6 100755 --- a/t/t0100-previous.sh +++ b/t/t0100-previous.sh @@ -56,5 +56,13 @@ test_expect_success 'merge @{-100} before checking out that many branches yet' ' test_must_fail git merge @{-100} ' +test_expect_success 'log -g @{-1}' ' + git checkout -b last_branch && + git checkout -b new_branch && + echo "last_branch@{0}" >expect && + git log -g --format=%gd @{-1} >actual && + test_cmp expect actual +' + test_done |