Skip to content
  • Jeff King's avatar
    interpret_branch_name(): handle auto-namelen for @{-1} · 13228c30
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    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 8cd4249c
    
     (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: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    13228c30