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

Fix embarrassing "git log --follow" bug

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Oct 8, 2007, 20:42 UTC
Message-ID
<alpine.LFD.0.999.0710081337490.4964@woody.linux-foundation.org>

It turns out that I completely broke "git log --follow" with my recent patch to revision.c ("Fix revision log diff setup, avoid unnecessary diff generation", commit b7bb760d5ed4881422673d32f869d140221d3564).

Why? Because --follow obviously requires the diff machinery to function, exactly the same way pickaxe does.

So everybody is away right now, but considering that nobody even noticed this bug, I don't think it matters. But for the record, here's the trivial one-liner fix (well, two, since I also fixed the comment).

Because of the nature of the bug, if you ask for patches when following (which is one of the things I normally do), the bug is hidden, because then the request for diff output will automatically also enable the diffs themselves.

So while "git log --follow <filename>" didn't work, adding a "-p" magically made it work again even without this fix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 revision.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 5d294be..e76da0d 100644
--- a/revision.c
+++ b/revision.c
@@ -1241,8 +1241,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 	if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
 		revs->diff = 1;
 
-	/* Pickaxe needs diffs */
-	if (revs->diffopt.pickaxe)
+	/* Pickaxe and rename following needs diffs */
+	if (revs->diffopt.pickaxe || revs->diffopt.follow_renames)
 		revs->diff = 1;
 
 	if (revs->topo_order)
Next: Linus Torvalds
Message 1 of 4 in “Fix embarrassing "git log --follow" bug”
  1. Linus TorvaldsOct 8, 2007
  2. Clean up "git log" format with DIFF_FORMAT_NO_OUTPUTLinus Torvalds, Oct 8, 2007
  3. Linus TorvaldsOct 8, 2007
  4. [take 2] Clean up "git log" format with DIFF_FORMAT_NO_OUTPUTLinus Torvalds, Oct 9, 2007

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.