* [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@
@ 2017-03-18 19:51 Andreas Gruenbacher
2017-03-18 20:18 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Gruenbacher @ 2017-03-18 19:51 UTC (permalink / raw)
To: git; +Cc: Andreas Gruenbacher, Jonas Fonseca
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@
2017-03-18 19:51 [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@ Andreas Gruenbacher
@ 2017-03-18 20:18 ` Junio C Hamano
2017-03-18 21:26 ` Andreas Gruenbacher
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2017-03-18 20:18 UTC (permalink / raw)
To: Andreas Gruenbacher; +Cc: git, Jonas Fonseca
Andreas Gruenbacher <agruenba@redhat.com> writes:
> 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.
Hmph, would ^A..B and ^A...B also be turned into B..A and B...A in a
similar way? I think the latter would not make much sense but ^A..B
might.
In any case, accepting ^rev^@ may make sense nevertheless.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@
2017-03-18 20:18 ` Junio C Hamano
@ 2017-03-18 21:26 ` Andreas Gruenbacher
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Gruenbacher @ 2017-03-18 21:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jonas Fonseca
On Sat, Mar 18, 2017 at 9:18 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Andreas Gruenbacher <agruenba@redhat.com> writes:
>
>> 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.
>
> Hmph, would ^A..B and ^A...B also be turned into B..A and B...A in a
> similar way? I think the latter would not make much sense but ^A..B
> might.
The previous patch supports neither. I agree about ^A...B, and I don't
think supporting ^A..B is relevant.
> In any case, accepting ^rev^@ may make sense nevertheless.
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-18 21:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 19:51 [PATCH] Inconsistency between git log and git rev-parse for ^HEAD^@ Andreas Gruenbacher
2017-03-18 20:18 ` Junio C Hamano
2017-03-18 21:26 ` Andreas Gruenbacher
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).