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

Re: Git log follow question

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 26, 2010, 14:40 UTC
Message-ID
<alpine.LFD.2.00.1005260732490.3689@i5.linux-foundation.org>
In-Reply-To
<20100526055823.GA30409@coredump.intra.peff.net>
On Wed, 26 May 2010, Jeff King wrote:
> > 
> > Doing it "right" is actually a _lot_ more complex than that.
> 
> Did you mean doing history rewriting right is more complex than that,
History rewriting with changing pathspecs.
> or did you mean that handling multiple follow pathspecs is more complex 
> than pathspec-widening

No, the "expand pathspec to cover the newly found rename" part is pretty simple. But the fact that the pathspec changes over the history inevitably leads to the problem of finding commits in the right order.

The thing is, if the pathspec is history-dependent, then that means that in order to get it right, you should walk the history in topological order in order to get a proper pathspec. But you don't know what the topological order _is_ until you've walked the history - which in turn means that if you want to get "perfect" results, you need to walk the history first, and then have a separate phase to do the pathspec.

That's actually what the current --follow kind of does, but because the current follow isn't even trying to get a proper pathspec in the bigger picture (it only tracks a single global filename rather than widening the net), it also skips the topological part, since even if it did things in topological order it would _still_ get things wrong.

Doing it really right also actually would require making the pathspec be a per-commit thing rather than a single global one. Otherwise you get other odd effects, if that filename has ever been something different. But since you only do a simple widening, I guess you don't much care (you already get odd effects if there was a criss-cross rename, and will end up picking up the history for _both_ files, rather than just the original one).

				Linus
Previous: Jeff KingNext: Albert Krawczyk
Message 10 of 12 in “Git log follow question”
  1. Albert KrawczykMay 14, 2010
  2. Bo YangMay 14, 2010
  3. Jeff KingMay 14, 2010
  4. Linus TorvaldsMay 14, 2010
  5. Martin LanghoffMay 14, 2010
  6. Linus TorvaldsMay 14, 2010
  7. Jeff KingMay 25, 2010
  8. Linus TorvaldsMay 25, 2010
  9. Jeff KingMay 26, 2010
  10. Linus TorvaldsMay 26, 2010
  11. Albert KrawczykMay 14, 2010
  12. Albert KrawczykMay 14, 2010

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.