Why is my git file history lost after doing relocation refactoring in eclipse?

I performed several refactors in eclipse where I move a large set of files to another java package. This often leads to a large number of files being automatically updated to resolve links. Thus, fixations in these cases tend to be quite large.

I assumed that git tracks renames, and I could use git log --follow to track history through renames, but git did not track renames.

I did smaller refactoring operations in eclipse where it intercepts when fixing. The only difference seems to be the amount of commits.

Any ideas?

+6
source share
1 answer

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

  • You may need to specify a low -M percent to git log to detect renames. If more than a few percent of the file is modified, git log (and git diff ) will not treat the add / remove pair as a rename. If the moved files were very small and the required content changes (for example, for package names), they may exceed this threshold.
  • You may also need to specify a value for -l , which determines the maximum number of potential renames to evaluate. In large entries, you can be much higher than this, and therefore Git does not evaluate the renaming, so the log operation is not too long. (Rename detection is an O (n ^ 2) operation, where n is the number of add / delete pairs that need to be taken into account, so the time taken to process each commit in a log operation, looking for renames, exponentially increases with the number of add / remove permutations. )

For a more detailed description of these options, see the git -log man page.

+7
source

Source: https://habr.com/ru/post/926985/


All Articles