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

Re: log: option "--follow" not the default for a single file?

From
Jeff King <peff@peff.net>
Date
Nov 30, 2011, 06:37 UTC
Message-ID
<20111130063743.GB5317@sigill.intra.peff.net>
In-Reply-To
<CAN0XMOJsiw0c4j_LooRrj80CVVy0omGLUcjDg4QoD4mNS3y1GA@mail.gmail.com>
On Tue, Nov 29, 2011 at 07:25:47PM +0100, Ralf Thielow wrote:
> Why is the option "--follow" not the default if the log-command
> is used with a single file? Many GUI tools don't show me the
> full history of a single file if there was a rename in it.
A few reasons, I think:
  1. There is no such thing as giving log a single file. You give it a
     pathspec. That may happen to match a single file in the current
     revision, but to git it is actually a prefix-limiting pattern, and
     "git log foo" will match "foo" if it is a file, or "foo/bar" if it
     was a directory in a previous revision.
  2. It can be slower than a regular traversal, since we have to do
     rename detection whenever we see a deletion. In practice I don't
     think it is much slower, though (mainly because files don't get
     moved all that much).
  3. The implementation is a bit hacky.  In particular, things like
     history simplification and parent rewriting won't work. So a
     GUI tool that tries to draw a graph will make a very ugly graph.
     Try looking at "gitk $file" and then "gitk --follow $file" in some
     repository (if you don't have gitk, try "git log --graph
     --oneline"). Even with a linear history, things look ugly: there
     are big gaps in the graph. But in a branch-y history, it's
     downright unreadable, as you have parallel disconnected lines of
     history next to each other.

I think (1) and (3) are fixable by improving the implementation (making --follow respect pathspecs and not single files, and having it work at the history-simplification level). And then you might argue that (2) isn't a big deal, and we can turn on --follow all the time.

-Peff
Previous: Ralf ThielowNext: Junio C Hamano
Message 2 of 7 in “log: option "--follow" not the default for a single file?”
  1. Ralf ThielowNov 29, 2011
  2. Jeff KingNov 30, 2011
  3. Junio C HamanoNov 30, 2011
  4. Ralf ThielowNov 30, 2011
  5. Jeff KingDec 1, 2011
  6. Ralf ThielowDec 1, 2011
  7. Jeff KingDec 1, 2011

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.