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

Re: gsoc - Better git log --follow support

From
Jeff King <peff@peff.net>
Date
Mar 23, 2011, 16:20 UTC
Message-ID
<20110323162023.GC30337@sigill.intra.peff.net>
In-Reply-To
<AANLkTi=woLeveur6gKnSXTRzmS8nB0o4M9HegJ+GNUCa@mail.gmail.com>
On Wed, Mar 23, 2011 at 12:23:45AM +0100, Michał Łowicki wrote:
Show 7 quoted lines
> >  # But now look at it in gitk. Commit 4 is included as a boundary
> >  # commit, but we fail to notice that it connects to three. And we
> >  # don't see commit 3 connecting to anything, and commit 1 is missing
> >  # entirely.
> >  gitk --follow newfile
> 
> Why commit 4 is displayed here (changes only file2) ?

It's part of how gitk shows the graph. It shows all of the commits you asked for with blue nodes, and then it shows the "boundary" commits with a special white node. This lets you distinguish between actual root commits (i.e., ones with no parents) and ones whose parents are simply uninteresting to the current query.

> # git log with graph works here OK. It displays six -- five .. --
> three .. - one .In this case results shouldn't be similar to gitk ?
> git log --graph --follow newfile

Sort of. Notice the "..." in the output (it is easier to see with "git log --graph --oneline --follow newfile). It is not showing the simplified history, but instead indicates that there were some commits omitted in between the two points. It doesn't make the output terrible in such a simple linear case. But consider a case with branching:

  # Our A-B-C repo
  git init repo && cd repo
  echo content >file1 && git add file1 && git commit -m one
  echo content >file2 && git add file2 && git commit -m two
  echo content >>file1 && git add file1 && git commit -m three
  # Now make a side branch that also touches file1
  git checkout -b side HEAD^
  echo content >>file1 && git commit -a -m four
  # And merge them back to together
  git merge master
  # And then do our other commits with rename on top
  echo content >>file2 && git commit -a -m five
  git mv file1 newfile && git commit -m six
  echo content >>newfile && git commit -a -m seven

Showing "git log --graph --oneline --follow newfile" becomes a bit more confusing. A simplified history would show "six" as the merge between the two branches, but here it happens at some indeterminate point in the history that is not shown.

And again, this is a simple example. For something more complex, try this in git.git:

  # We know builtin-add.c got renamed to builtin/add.c, so
  # let's cheat and tell git which paths we're interested in.
  # The resulting graph is pretty readable, and is more or less what we
  # would want from --follow.
  git log --oneline --graph -- builtin-add.c builtin/add.c
  # Now try it with --follow. Not so pretty.
  git log --oneline --graph --follow builtin/add.c
-Peff
Previous: Michał ŁowickiNext: Junio C Hamano
Message 5 of 12 in “gsoc - Better git log --follow support”
  1. Michał ŁowickiMar 19, 2011
  2. Jakub NarebskiMar 19, 2011
  3. Jeff KingMar 21, 2011
  4. Michał ŁowickiMar 22, 2011
  5. Jeff KingMar 23, 2011
  6. Junio C HamanoMar 23, 2011
  7. Jeff KingMar 23, 2011
  8. Junio C HamanoMar 23, 2011
  9. Jeff KingMar 23, 2011
  10. Michał ŁowickiApr 13, 2011
  11. Jonathan NiederApr 15, 2011
  12. Michał ŁowickiApr 15, 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.