git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Can `git blame` show the date that each line was merged?

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 4, 2013, 17:28 UTC
Message-ID
<7vfvwx9461.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130604155605.GA15953@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 17 quoted lines
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 57a487e..0fb67af 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -1199,6 +1199,8 @@ static int num_scapegoats(struct rev_info *revs, struct commit *commit)
>  {
>  	int cnt;
>  	struct commit_list *l = first_scapegoat(revs, commit);
> +	if (revs->first_parent_only)
> +		return l ? 1 : 0;
>  	for (cnt = 0; l; l = l->next)
>  		cnt++;
>  	return cnt;
>
> (though I suspect it would interact oddly with the "--reverse" option,
> and we would want to either declare them mutually exclusive or figure
> out some sane semantics).

It is entirely unclear who the first child is, so I tend to think that they have to be mutually exclusive.

Show 14 quoted lines
>> Aside: in some trial and error I notice this oddity:
>> 
>>     $ git blame --merges
>>     usage: git blame [options] [rev-opts] [rev] [--] file
>> 
>>         [rev-opts] are documented in git-rev-list(1)
>>     ...
>
> Your problem is not the presence of "--merges" here, but that you forgot
> the necessary "file" argument. Try "git blame --merges foo.c".
>
> However, this suffers from the same problem as --first-parent, in that
> it is accepted but not respected. Doing so would not be impossible, but
> it is a little more than the two-liner above.

What the command does when it "respects" it is unclear to me. In a history like this:

---A---B---C
    \       \
     E---F---G---H

and starting at H, pretend everything that happened in, B, C, E and F since A was done by G? Who gets the blame for what A or H did?

Previous: Matt McClureNext: Jeff King
Message 4 of 5 in “Can `git blame` show the date that each line was merged?”
  1. Matt McClureJun 4, 2013
  2. Jeff KingJun 4, 2013
  3. Matt McClureJun 4, 2013
  4. Junio C HamanoJun 4, 2013
  5. Jeff KingJun 4, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.