6

I've performed several refactors in eclipse where I move a large set of files to another java package. These often result in a lot of files being automatically updated to resolve references. So, the commits in these cases tend to be quite large.

I assumed that git tracked the renames and I could use git log --follow to follow the history back through the rename, but git didn't track the renames.

I've performed smaller refactor operations in eclipse where the renames are detected on commit. The only difference seems to be the size of the commits.

Any ideas?

2
  • To add to this, it looks like the EGit eclipse plugin has no way of specifying the -M or -l values for git log (as mentioned by cdhowie). So, you'll have to hit the CLI if you want to use those flags. Commented Oct 4, 2012 at 23:13
  • 2
    EGit (well, JGit to be exact) respects the diff.renameLimit setting. The default is 200, but you can configure it to a higher value in your global or per-repository git config. Commented Oct 9, 2012 at 10:46

1 Answer 1

7

Git does not track renames in history at all, but git log can heuristically detect renames based on the commit contents.

  • You may need to specify a low -M percent to git log in order for the renames to be detected. If more than some percent of the file has changed, git log (and git diff) won't consider an add/delete pair to be a rename. If the files moved were very small and required content changes (to package names for example) then they might exceed this threshold.
  • You may need to specify a value for -l too, which specifies the maximum number of potential renames to evaluate. In large commits, you may very well be exceeding this, and so Git doesn't evaluate renames to keep the log operation from taking too long. (Detecting renames is an O(n^2) operation, where n is the number of add/delete pairs that need to be considered, so the time taken to process each commit in a log operation looking for renames increases exponentially with the number of add/delete permutations.)

See the git-log manpage for more detailed descriptions of these options.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.