From: Junio C Hamano Date: Tue, 17 Jan 2017 22:49:26 +0000 (-0800) Subject: Merge branch 'jk/rev-parse-symbolic-parents-fix' into maint X-Git-Tag: v2.11.1~63 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7b0490f81c7c9ce5a93f92ddd3bf7cae78a073e8?hp=-c Merge branch 'jk/rev-parse-symbolic-parents-fix' into maint "git rev-parse --symbolic" failed with a more recent notation like "HEAD^-1" and "HEAD^!". * jk/rev-parse-symbolic-parents-fix: rev-parse: fix parent shorthands with --symbolic --- 7b0490f81c7c9ce5a93f92ddd3bf7cae78a073e8 diff --combined builtin/rev-parse.c index cfb0f1510c,c352f2f8b2..ff13e59e1d --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@@ -342,11 -342,16 +342,16 @@@ static int try_parent_shorthands(const for (parents = commit->parents, parent_number = 1; parents; parents = parents->next, parent_number++) { + char *name = NULL; + if (exclude_parent && parent_number != exclude_parent) continue; + if (symbolic) + name = xstrfmt("%s^%d", arg, parent_number); show_rev(include_parents ? NORMAL : REVERSED, - parents->item->object.oid.hash, arg); + parents->item->object.oid.hash, name); + free(name); } *dotdot = '^'; @@@ -671,9 -676,8 +676,9 @@@ int cmd_rev_parse(int argc, const char filter &= ~(DO_FLAGS|DO_NOREV); verify = 1; abbrev = DEFAULT_ABBREV; - if (arg[7] == '=') - abbrev = strtoul(arg + 8, NULL, 10); + if (!arg[7]) + continue; + abbrev = strtoul(arg + 8, NULL, 10); if (abbrev < MINIMUM_ABBREV) abbrev = MINIMUM_ABBREV; else if (40 <= abbrev)