threads / bug / 28535

Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'

Subject: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'

## tl;dr

4 messages between Sep 30, 2011 and Oct 2, 2011.

replies: 3people: 2as markdown or json

Alexander Pepper· Sep 30, 2011, 15:32 UTC · lore
Hello Again.
I'm not really sure, if this is a bug or if I am missing something, but the following is quite annoying:

$ git version git version 1.7.6.3 $ git clone https://github.com/voldemort/voldemort.git $ cd voldemort $ git log --numstat --find-copies dd4e90f9 ... 3 15 contrib/ec2-testing/src/java/voldemort/utils/{StopClusterException.java => ClusterOperation.java} $ git log --numstat dd4e90f9 -- contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java ... 23 0 contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java $ git log --numstat --follow dd4e90f9 -- contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java ... 6 10 src/java/voldemort/annotations/concurrency/Immutable.java => contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java

So git log with copy and rename detection on (--find-copies) tells me, that the file StopClusterException.java is copied to ClusterOperation.java. But If I ask git log for that specific file with --follow git claims a copy from Immutable.java to ClusterOperation.java!
I understand, that git doesn't record renames and copies, but only detects it afterwords. But at least I would expect, that git detects the same thing consistently between to (quite) alike flags.
I also tried adding "--find-copies" and "--find-copies-harder" to 'git log --numstat --follow dd4e90f9', but they also result in claiming Immutable.java as the origin of the copy.
Is there a flag to get consistent results between the two or is this really a bug?

Greetings from Berlin Alex

Jeff King· Sep 30, 2011, 21:38 UTC · re: Alexander Pepper · lore

Re: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'

On Fri, Sep 30, 2011 at 05:32:38PM +0200, Alexander Pepper wrote:
Show 5 quoted lines
> So git log with copy and rename detection on (--find-copies) tells me,
> that the file StopClusterException.java is copied to
> ClusterOperation.java. But If I ask git log for that specific file
> with --follow git claims a copy from Immutable.java to
> ClusterOperation.java!
I think that --follow uses --find-copies-harder. Did you try:
  git log --numstat --find-copies-harder dd4e90f9
? Does it find Immutable.java as the source?
-Peff
Alexander Pepper· Oct 2, 2011, 15:10 UTC · re: Jeff King · lore

Re: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'

Am 30.09.2011 um 23:38 schrieb Jeff King:
Show 15 quoted lines
> On Fri, Sep 30, 2011 at 05:32:38PM +0200, Alexander Pepper wrote:
> 
>> So git log with copy and rename detection on (--find-copies) tells me,
>> that the file StopClusterException.java is copied to
>> ClusterOperation.java. But If I ask git log for that specific file
>> with --follow git claims a copy from Immutable.java to
>> ClusterOperation.java!
> 
> I think that --follow uses --find-copies-harder. Did you try:
> 
>  git log --numstat --find-copies-harder dd4e90f9
> 
> ? Does it find Immutable.java as the source?
> 
> -Peff
Using 'git log --numstat --find-copies-harder dd4e90f9' yields "immutable.java" as you expected:

$ git log --numstat --find-copies-harder dd4e90f9 [...] 6 10 src/java/voldemort/annotations/concurrency/Immutable.java => contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java

So is there a way to tell --follow to only use --find-copies instead of --find-copies harder? And what is the advantage of using "--find-copies-harder" over "--find-copies"?

Greetings from Berlin Alex

-- 
Alexander Pepper
pepper@inf.fu-berlin.de
Jeff King· Oct 2, 2011, 15:25 UTC · re: Alexander Pepper · lore

Re: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'

On Sun, Oct 02, 2011 at 05:10:26PM +0200, Alexander Pepper wrote:
Show 5 quoted lines
> Using 'git log --numstat --find-copies-harder dd4e90f9' yields "immutable.java" as you expected:
> 
> $ git log --numstat --find-copies-harder dd4e90f9
> [...]
> 6       10      src/java/voldemort/annotations/concurrency/Immutable.java => contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java
OK. That at least explains what's going on.
> So is there a way to tell --follow to only use --find-copies instead
> of --find-copies harder?
No, it's hard-coded.
> And what is the advantage of using "--find-copies-harder" over "--find-copies"?
It finds more copies. The rename detection works like this:
  --find-renames: for each newly-created file, consider any deleted
                  files as possible sources
  --find-copies: like above, but also consider any modified files as
                 possible sources
  --find-copies-harder: like above, but consider any file in the
                        repository as a possible source

So in theory --find-copies-harder is the most accurate, but it is also the most expensive. We can afford to do it for --follow since we're only considering a small subset of the possible destinations.

So git is saying that your immutable.java is actually a better match; it's just that we don't usually find it because it wasn't modified in the same commit. Have you looked at the contents? Is it actually a better match, or is git wrong?

-Peff

← back to recent threads