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

Re: Blamming a diff between two commits?

From
JHJan Hudec <bulb@ucw.cz>
Date
Feb 22, 2009, 19:11 UTC
Message-ID
<20090222191138.GC6504@efreet.light.src>
In-Reply-To
<vpqtz6mpas3.fsf@bauges.imag.fr>
On Sun, Feb 22, 2009 at 19:49:16 +0100, Matthieu Moy wrote:
Show 42 quoted lines
> Jan Hudec <bulb@ucw.cz> writes:
> > On Tue, Feb 17, 2009 at 10:16:17 -0300, Samuel Lucas Vaz de Mello wrote:
> >> Hi,
> >> 
> >> Is there any way to git blame (or annotate) a diff between two commits?
> >> [...]
> >
> > What about doing a diff of the blames? It should do the same thing (except
> > the +/- would be at the begining of the lines). Well, not exactly, because if
> > there was a change, that was reverted again, blames would change, so it would
> > appear here, but that's probably rare enough to ignore (if you don't even
> > want to see it rather than not).
> 
> I don't think that would do it.
> 
> Suppose I have the following history (in a one-line file) :
> 
> revision: R1 -> R2 -> R3 -> R4 -> R5 -> R6
> content:  A  -> B  -> B  -> C  -> D  -> E 
> 
> If I do a blame at revision R3, I'll get
> 
> R2 B
> 
> Then, at revision R6, I'd get
> 
> R6 E
> 
> so the diff will be
> 
> - R2 B
> + R6 E
> 
> while the original poster actually wanted
> 
> - R3 B
> + R6 E
> 
> In the first case, the annotation for - lines tell where the removed
> line had been introduced before, while the second case tells up to
> which revision the line has been existing (or, it could show the
> revision which removed it, R4 here).
You are right, it is something different.

Both are probably useful, though -- knowing where the deleted line was introduced would be useful so you can look up rationale for the old code in the respective commit message and check whether the new version does not miss any points mentioned there. Provided you have good descriptions in the comments, of course.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Matthieu Moy
Message 10 of 10 in “Blamming a diff between two commits?”
  1. Samuel Lucas Vaz de MelloFeb 17, 2009
  2. Johannes SchindelinFeb 17, 2009
  3. Samuel Lucas Vaz de MelloFeb 17, 2009
  4. Johannes SchindelinFeb 17, 2009
  5. Matthieu MoyFeb 17, 2009
  6. Thomas RastFeb 17, 2009
  7. Thomas RastFeb 20, 2009
  8. Jan HudecFeb 22, 2009
  9. Matthieu MoyFeb 22, 2009
  10. Jan HudecFeb 22, 2009

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.