From: Andreas Gruenbacher <agruenba@redhat.com>
To: git@vger.kernel.org
Cc: Andreas Gruenbacher <agruenba@redhat.com>,
Jonas Fonseca <jonas.fonseca@gmail.com>
Subject: [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@
Date: Sat, 18 Mar 2017 20:51:36 +0100 [thread overview]
Message-ID: <1489866696-17487-1-git-send-email-agruenba@redhat.com> (raw)
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
next reply other threads:[~2017-03-18 19:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-18 19:51 Andreas Gruenbacher [this message]
2017-03-18 20:18 ` [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@ Junio C Hamano
2017-03-18 21:26 ` Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489866696-17487-1-git-send-email-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=git@vger.kernel.org \
--cc=jonas.fonseca@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).