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

git log --follow doesn't follow a rename over a merge

From
James Blackburn <jamesblackburn@gmail.com>
Date
Jun 15, 2011, 22:41 UTC
Message-ID
<BANLkTimjEp0ntq80qttT9uZN2YGuhsnZBw@mail.gmail.com>
Hi All,

I'm trying, without success, to get git log to show the history of a file across a rename.  I'm using git version 1.7.5.4, and git blame has no such issues tracking the source of the lines.

This is part of a CVS migration.  In the repo a number of directories were committed atomically, but they originated from another CVS repository.  During the migration, I've grafted the history from the originating repository onto the destination repo's commit of the content.  Blame looks good, but log won't find the rename.

Git blame attributes 3 files:
> git blame dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpoints.java | awk '{print $2}' |sort |uniq

dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpoints.java plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBreakpoints.java plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java

Git log shows:
> git log --oneline dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpoints.java

70237c3 Bug 315439 Fix up copyright 6a53ab4 [290074] - [services][breakpoints] IBreakpointDMData interface should extend IDMData 640102e partial fix for Bugzilla 265882 5b47187 Migrated DSF and DSF-GDB to the CDT project.

And it shows one fewer if I turn on --follow (with as many combinations of -M -C as I've tried):

> git log -M -C -C --follow  --oneline dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpoints.java

70237c3 Bug 315439 Fix up copyright 6a53ab4 [290074] - [services][breakpoints] IBreakpointDMData interface should extend IDMData 640102e partial fix for Bugzilla 265882

My new merge commit is 5b47187 (when the content first arrived in the repo):
> git show 5b47187
commit 5b471873662a87a77cfd854c98fca9c9948aa878
Merge: 4709306 c1e6da2
...
I can see the file in the parent of the merge:
> git show c1e6da2:plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java

... and the renamed file after the merge:

> git show 5b47187:dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IBreakpoints.java

... (Neither file exists on the 4709 side)

Interestingly the tricks mentioned here (http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo) for working out where a file was removed, produce no output:

> git log --follow --diff-filter=D --oneline -- plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java
> git rev-list -n 1 HEAD -- plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.javaJB

But log does work for the file if follow is specified (output with --diff-filter is empty...):

> git log --follow --oneline -- plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java

10580b5 Updated copyright statements. 17585c3 [218577] Cleaned up IBreakpoints interface. ...

Have I done something wrong in grafting history like this, or is this just a problem with the way git log --follow tracks renames?

The repo's here if anyone's interested (it's 85M...): git://github.com/jamesblackburn/org.eclipse.cdt

Many thanks for any insight. Cheers, James

Next: Jakub Narebski
Message 1 of 14 in “git log --follow doesn't follow a rename over a merge”
  1. James BlackburnJun 15, 2011
  2. Jakub NarebskiJun 16, 2011
  3. James BlackburnJun 16, 2011
  4. James BlackburnJun 16, 2011
  5. Jeff KingJun 16, 2011
  6. Jeff KingJun 16, 2011
  7. Junio C HamanoJun 16, 2011
  8. Jeff KingJun 16, 2011
  9. James BlackburnJun 16, 2011
  10. James BlackburnJun 16, 2011
  11. Junio C HamanoJun 16, 2011
  12. James BlackburnJun 16, 2011
  13. James BlackburnJun 16, 2011
  14. James BlackburnJun 16, 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.