HomePhabricator

(stable) In Git, only use "--find-copies-harder" on small diffs

Description

(stable) In Git, only use "--find-copies-harder" on small diffs

Summary:
Ref T10423. This flag can cause git diff to take an enormously long time (the problem case was a 5M line, 20K file commit).

Instead:

  • Run without the flag first.
  • If that shows that the diff is definitely small, try again with the flag.
  • If that works, return the slower, better output.
  • If the fast diff affects too many paths or generating the slow diff takes too long, return the faster, slightly worse output.

The quality of the output differs in how well Git is able to detect "M" and "C" (moves and copies of files).

For example, if you copy src/ to srcpro/, the fast output may not show that you copied files. The slow output will.

I think this is rarely useful for large copies anyway: it's interesting if a 1-2 file diff is a copy, but usually obvious/uninteresting if a 500-file diff is a copy.

Test Plan:

  • Ran bin/repository reparse --change rXnnn on Git changes.
  • Saw fast and slow commands execute normally.
  • Tried on a large diff, saw only the fast command execute.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10423

Differential Revision: https://secure.phabricator.com/D16266