From: Junio C Hamano <gitster@pobox•com>
To: Jeff King <peff@peff•net>
Cc: Stephen Connolly <stephen.alan.connolly@gmail•com>, git@vger•kernel.org
Subject: Re: [Feature Request] git blame showing only revisions from git rev-list --first-parent
Date: Fri, 11 Sep 2015 09:35:13 -0700 [thread overview]
Message-ID: <xmqqa8ss29tq.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20150911140133.GA14311@sigill.intra.peff.net> (Jeff King's message of "Fri, 11 Sep 2015 10:01:33 -0400")
Jeff King <peff@peff•net> writes:
> I'm not too familiar with the code, but this _seems_ to work for me:
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 21321be..2e03d47 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -1375,6 +1375,10 @@ static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit
> static int num_scapegoats(struct rev_info *revs, struct commit *commit)
> {
> struct commit_list *l = first_scapegoat(revs, commit);
> + if (!l)
> + return 0;
> + if (revs->first_parent_only)
> + return 1;
> return commit_list_count(l);
> }
>
> I suspect it doesn't work at all with `--reverse`. I also have the
> nagging feeling that this could be handled inside revision.c with
> parent-rewriting, but I don't really know.
I am not sure how well --children, which is what we use from
revision.c, works with --first-parent flag passed to the revision
walking machinery. If it already does the right thing, then the
revs.children decoration that collects all children of any given
commit should automatically give its "sole child" (in the world
limited to the first-parent chain) from first_scapegoat().
And if it does not, perhaps that is what we would want to fix,
i.e. making sure rev-list --first-parent --children does what
people would expect.
> But "git blame --first-parent <file>" seems to behave sanely in git.git
> with this.
It is intresting to see that the above is the only thing necessary,
as a naive way to try all parents would be to do:
for (sg = first_scapegoat(...); sg; sg = sg->next)
assign blame to sg;
take the remainder ourselves;
in which case, a better place to patch would be first_scapegoat(),
not this function, so that we will always see zero or one element
parent list returned from the function.
But in reality, the code instead does this:
num_sg = num_scapegoats(...);
for (i = 0, sg = first_scapegoat(...);
i < num_sg && sg;
i++, sg = sg->next)
assign blame to sg;
take the remainder ourselves;
so you do not have to touch first_scapegoat() at all.
I do not offhand know if this was a sign of foresight in the
original, or just an overly redundant programming ;-).
next prev parent reply other threads:[~2015-09-11 16:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-11 10:47 [Feature Request] git blame showing only revisions from git rev-list --first-parent Stephen Connolly
2015-09-11 14:01 ` Jeff King
2015-09-11 15:31 ` Stephen Connolly
2015-09-11 16:35 ` Junio C Hamano [this message]
2015-09-11 19:06 ` Junio C Hamano
2015-09-12 3:30 ` Jeff King
2015-09-12 8:29 ` Junio C Hamano
2015-09-12 22:09 ` Philip Oakley
2015-09-13 10:07 ` Jeff King
2015-09-14 5:19 ` Junio C Hamano
2015-09-15 10:05 ` Jeff King
2015-09-16 1:14 ` Junio C Hamano
2015-09-16 17:37 ` Jeff King
2015-09-17 17:03 ` Junio C Hamano
2015-10-18 11:38 ` Max Kirillov
2015-10-18 17:41 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqa8ss29tq.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=peff@peff$(echo .)net \
--cc=stephen.alan.connolly@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox