]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/rev-parse-symbolic-parents-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 16 Dec 2016 23:27:47 +0000 (15:27 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Dec 2016 23:27:47 +0000 (15:27 -0800)
"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

1  2 
builtin/rev-parse.c

diff --combined builtin/rev-parse.c
index cfb0f1510c59674abe68fb67ff45142b5c92ac89,c352f2f8b25b0bce7d3c9f2dc48eeb7f9cce0e7c..ff13e59e1dbd200b6e7cf7d1c508b620b19e8cc7
@@@ -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)