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

Proper tracking of copies in git log and others

From
LKLasse Kärkkäinen <tronic+dfhy@trn.iki.fi>
Date
Jul 4, 2009, 16:24 UTC
Message-ID
<4A4F8258.5070701@trn.iki.fi>

Getting full history of a file, including that beyond copies, is rather important and apparently not currently supported by git tools.

An example use case:

# Create repository mkdir courses cd courses git init # Course 2007 mkdir -p 2007/exercise1 echo Hello > 2007/exercise1/description.txt mkdir 2007/exercise2 echo World > 2007/exercise2/description.txt git add 2007 git commit -m "Course 2007" # Course 2008 mkdir -p 2008/exercise1 echo New one > 2008/exercise1/description.txt git add 2008 git commit -m "Course 2008 exercise 1 (new)" cp -R 2007/exercise1 2008/exercise2 git add 2008/exercise2 git commit -a -m "Course 2008 exercise 2 (from 2007 exercise 1)" # Course 2009 cp -R 2008 2009 git add 2009 git commit -m "Course 2009 recycled entirely from 2008"

Now, if we do git log --follow 2009/exercise2/description.txt or 2009/exercise2, it only prints the "Course 2009" commit instead of the full history because --follow doesn't follow copies. What we actually want is:

commit 9e17341497b29735bc55b6631b43db6e2f50ed30
Author: Lasse Karkkainen <tronic@trn.iki.fi>
Date:   Sat Jul 4 19:05:57 2009 +0300
     Course 2009 recycled entirely from 2008
commit 8fd13a8667f0bc5c4851b366864a207fa85519bc
Author: Lasse Karkkainen <tronic@trn.iki.fi>
Date:   Sat Jul 4 19:05:57 2009 +0300
     Course 2008 exercise 2 (from 2007 exercise 1)
commit 593346660872ada80ba751688fffc7af7a31e124
Author: Lasse Karkkainen <tronic@trn.iki.fi>
Date:   Sat Jul 4 19:05:57 2009 +0300
     Course 2007
Note: the "Course 2008 exercise 1 (new)" commit is not listed, as it is 
unrelated to 2009/exercise2.

Some nice people from #git suggested various commands that would find the previous version (e.g. 2008/exercise2) etc, but none of those got even close to getting this full history over multiple copies, with log messages.

It would be useful if the git tools could produce history like this with all the tools (log, blame, gitk, etc), preferably with proper branching guesses (guesses because there is no info on where the copy came from), but even a linear history (sorted by commit time?) would do much better than not having anything.

Next: Sean Estabrooks
Message 1 of 6 in “Proper tracking of copies in git log and others”
  1. Lasse KärkkäinenJul 4, 2009
  2. Sean EstabrooksJul 4, 2009
  3. Lasse KärkkäinenJul 14, 2009
  4. Graeme GeldenhuysJul 7, 2009
  5. Michael J GruberJul 7, 2009
  6. Avery PennarunJul 7, 2009

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.