From: Jeff King <peff@peff.net>
To: Stephen Connolly <stephen.alan.connolly@gmail.com>
Cc: Junio C Hamano <gitster@pobox.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 10:01:33 -0400 [thread overview]
Message-ID: <20150911140133.GA14311@sigill.intra.peff.net> (raw)
In-Reply-To: <CA+nPnMx1tkwTRckUjhg6LD055n-jzYDTKsH2sz-0PXPfJiy_tA@mail.gmail.com>
On Fri, Sep 11, 2015 at 11:47:30AM +0100, Stephen Connolly wrote:
> A command line option to `git blame HEAD -- path` that instructs that
> the revisions of blame be the revisions where the change was applied
> to the current branch not the revision where the change first
> originated (i.e. limit commits to `git rev-list --first-parent HEAD`)
>
> I can get what I want with the following:
>
> git rev-list --first-parent HEAD | awk '{print p " " $0}{p=$0}' >
> tmpfile && git blame -b -S tmpfile HEAD -- path && rm tmpfile
>
> But that is a rather ugly command. Could we have something built in to
> git blame to make this much easier for users?
I agree this would be a useful feature. Though blame takes rev-list
options, it doesn't use the stock rev-list traversal internally, so it
has to handle first-parent itself.
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.
But "git blame --first-parent <file>" seems to behave sanely in git.git
with this.
-Peff
next prev parent reply other threads:[~2015-09-11 14:01 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 [this message]
2015-09-11 15:31 ` Stephen Connolly
2015-09-11 16:35 ` Junio C Hamano
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=20150911140133.GA14311@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=stephen.alan.connolly@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.
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 NNTP newsgroup(s).