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

Re: What's cooking in git.git (topics)

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jun 21, 2007, 17:16 UTC
Message-ID
<alpine.LFD.0.98.0706211005520.3593@woody.linux-foundation.org>
In-Reply-To
<7v4pl1zsd7.fsf@assigned-by-dhcp.pobox.com>
On Thu, 21 Jun 2007, Junio C Hamano wrote:
Show 9 quoted lines
> 
> Also I am not convinced its handling of merges is sane.  If you
> have an ancestry graph like this, and the commit A renames the
> followed path, it would show the file _before_ rename, which is
> very good.
> 
>       o-------B---A---o----o
>                      /  
>         o----C------'

I agree. That's even what I tried to explain (but your graph is better) in my commit message, when I was talking about how it linearizes the history in "git log" order, and decides that renames happen "within that linearized" world.

You can actually see an *example* of this by doing
	git log --stat --follow arch/i386/pci/common.c

on the old historical Linux archive (the BK import one, not the bkcvs import - the latter has been linearized by bkcvs so won't show concurrent development anyway).

What you get is:
	[ ... ]
	commit f9001d4262148fbfb7ecdcb88c73d9791c1ac0ad
	Author: Greg Kroah-Hartman <greg@kroah.com>
	Date:   Mon May 6 20:18:16 2002 -0700
	
	    Move arch/i386/kernel/pci/ to arch/i386/pci/
	
	 arch/i386/{kernel => }/pci/common.c |    0
	 1 files changed, 0 insertions(+), 0 deletions(-)
	
	commit bbb283cca10b2d2c935ae35327620ebae07f7d80
	Author: Patrick Mochel <mochel@segfault.osdl.org>
	Date:   Mon May 6 20:09:44 2002 -0700
	
	    Move arch/i386/kernel/pci/ to arch/i386/pci/
	
	 arch/i386/kernel/pci/common.c |  206 -----------------------------------------
	 1 files changed, 0 insertions(+), 206 deletions(-)
	[ ... ]

and this is an artifact of two _concurrent_ directory moves, and look at what "git log --follow" did: it actually found the rename (we looked at Greg's version first), but then *because* it found the rename, it is now starting to look at the *previous* name, which was

	arch/i386/kernel/pci/common.c

and when it then sees the rename in Pat's commit, it's no longer finding that previous entry as a "new file that got created" (which triggers the rename logic), but now it finds that filename has being *removed* (because the _old_ filename really did go away - it got renamed!)

This is 100% logical within that linearized history, but it's a bit surprising. But it's how "git log --follow" just works.

If you want to see the real history, you need to do it with "git blame", which actually understands about merges, or with some graphical viewer that would be extended to follow renames when it notices that a filename goes away.

But "git log" itself really fundamentally has no clue, and you really should see "git log" as a *linearization* thing. It linearizes the history by creating a one-dimensional streaming log. And within that linearized history, there can not be anything like "concurrent renames".

			Linus
Previous: Junio C HamanoNext: Linus Torvalds
Message 25 of 34 in “What's cooking in git.git (topics)”
  1. Junio C HamanoMay 13, 2007
  2. Julian PhillipsMay 13, 2007
  3. Junio C HamanoMay 13, 2007
  4. Julian PhillipsMay 14, 2007
  5. Daniel BarkalowMay 14, 2007
  6. Junio C HamanoMay 17, 2007
  7. Daniel BarkalowMay 17, 2007
  8. Junio C HamanoMay 17, 2007
  9. Daniel BarkalowMay 17, 2007
  10. Junio C HamanoMay 19, 2007
  11. Junio C HamanoMay 23, 2007
  12. Shawn O. PearceMay 24, 2007
  13. Junio C HamanoMay 29, 2007
  14. Junio C HamanoJun 2, 2007
  15. Johannes SchindelinJun 3, 2007
  16. Shawn O. PearceJun 3, 2007
  17. Nicolas PitreJun 3, 2007
  18. Dana HowJun 3, 2007
  19. Junio C HamanoJun 7, 2007
  20. Junio C HamanoJun 13, 2007
  21. Johannes SchindelinJun 13, 2007
  22. Linus TorvaldsJun 14, 2007
  23. Matthias LederhoferJun 18, 2007
  24. Junio C HamanoJun 21, 2007
  25. Linus TorvaldsJun 21, 2007
  26. Linus TorvaldsJun 21, 2007
  27. Junio C HamanoJun 25, 2007
  28. Jeffrey C. OllieJun 25, 2007
  29. Matthias LederhoferJun 26, 2007
  30. Junio C HamanoJun 27, 2007
  31. Matthias LederhoferJun 28, 2007
  32. Junio C HamanoJun 29, 2007
  33. Junio C HamanoJul 2, 2007
  34. Junio C HamanoJul 28, 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.