[PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@
From: Andreas Gruenbacher <agruenba@redhat.com>
Date: 2017-03-18 19:51:48
Subsystem:
the rest · Maintainer:
Linus Torvalds
Hello, the log and rev-parse commands both support the rev^@ syntax which stands for all parents of rev. The log command also supports ^rev^@ to exclude all of the parents of rev, but rev-parse does not. Should this be fixed? If so, the following patch would be a start. Thanks, Andreas -- rev-parse: Add support for ^rev^@ Add support for the ^rev^@ syntax to exclude all of the parents of rev. This syntax is already supported by git log. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> --- builtin/rev-parse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 2549643..ab84c49 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c@@ -293,7 +293,7 @@ static int try_difference(const char *arg) return 0; } -static int try_parent_shorthands(const char *arg) +static int try_parent_shorthands(int type, const char *arg) { char *dotdot; unsigned char sha1[20];
@@ -339,7 +339,7 @@ static int try_parent_shorthands(const char *arg) } if (include_rev) - show_rev(NORMAL, sha1, arg); + show_rev(type, sha1, arg); for (parents = commit->parents, parent_number = 1; parents; parents = parents->next, parent_number++) {
@@ -350,7 +350,7 @@ static int try_parent_shorthands(const char *arg) if (symbolic) name = xstrfmt("%s^%d", arg, parent_number); - show_rev(include_parents ? NORMAL : REVERSED, + show_rev(include_parents ? type : !type, parents->item->object.oid.hash, name); free(name); }
@@ -896,14 +896,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) /* Not a flag argument */ if (try_difference(arg)) continue; - if (try_parent_shorthands(arg)) - continue; name = arg; type = NORMAL; if (*arg == '^') { name++; type = REVERSED; } + if (try_parent_shorthands(type, name)) + continue; if (!get_sha1_with_context(name, flags, sha1, &unused)) { if (verify) revs_count++;
--
2.7.4