From: Junio C Hamano Date: Wed, 28 Jan 2009 23:00:27 +0000 (-0800) Subject: Merge branch 'tr/previous-branch' X-Git-Tag: v1.6.2-rc0~70 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8712b3cdb0495f5a56b91cd67e2697412447a886;p=git.git Merge branch 'tr/previous-branch' * tr/previous-branch: t1505: remove debugging cruft Simplify parsing branch switching events in reflog Introduce for_each_recent_reflog_ent(). interpret_nth_last_branch(): plug small memleak Fix reflog parsing for a malformed branch switching entry Fix parsing of @{-1}@{1} interpret_nth_last_branch(): avoid traversing the reflog twice checkout: implement "-" abbreviation, add docs and tests sha1_name: support @{-N} syntax in get_sha1() sha1_name: tweak @{-N} lookup checkout: implement "@{-N}" shortcut name for N-th last branch Conflicts: sha1_name.c --- 8712b3cdb0495f5a56b91cd67e2697412447a886 diff --cc sha1_name.c index 722fc35a6,7d95bbb27..5d0ac0263 --- a/sha1_name.c +++ b/sha1_name.c @@@ -307,10 -332,10 +332,10 @@@ static int get_sha1_basic(const char *s if (len == 40 && !get_sha1_hex(str, sha1)) return 0; - /* basic@{time or number} format to query ref-log */ + /* basic@{time or number or -number} format to query ref-log */ reflog_len = at = 0; - if (str[len-1] == '}') { + if (len && str[len-1] == '}') { - for (at = 0; at < len - 1; at++) { + for (at = len-2; at >= 0; at--) { if (str[at] == '@' && str[at+1] == '{') { reflog_len = (len-1) - (at+2); len = at;