{"thread":{"id":"28535","subject":"Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'","startedAt":"2011-09-30T15:32:38Z","lastAt":"2011-10-02T15:25:17Z","messageCount":4,"participants":["Alexander Pepper","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"176574","messageId":"DBC73B3F-2703-4651-AADA-233A9CC38AFD@inf.fu-berlin.de","threadId":"28535","inReplyTo":null,"subject":"Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'","fromName":"Alexander Pepper","fromEmail":"pepper@inf.fu-berlin.de","sentAt":"2011-09-30T15:32:38Z","receivedAt":"2011-09-30T15:32:38Z","isPatch":false,"sender":{"key":"pepper@inf.fu-berlin.de","avatar":null},"body":"Hello Again.\n\nI'm not really sure, if this is a bug or if I am missing something, but the following is quite annoying:\n\n$ git version\ngit version 1.7.6.3\n$ git clone https://github.com/voldemort/voldemort.git\n$ cd voldemort\n$ git log --numstat --find-copies dd4e90f9\n...\n3       15      contrib/ec2-testing/src/java/voldemort/utils/{StopClusterException.java => ClusterOperation.java}\n$ git log --numstat dd4e90f9 -- contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java\n...\n23      0       contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java\n$ git log --numstat --follow dd4e90f9 -- contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java\n...\n6       10      src/java/voldemort/annotations/concurrency/Immutable.java => contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java\n\nSo 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!\n\nI 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.\n\nI 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.\n\nIs there a flag to get consistent results between the two or is this really a bug?\n\nGreetings from Berlin\nAlex"},{"id":"176597","messageId":"20110930213841.GA9384@sigill.intra.peff.net","threadId":"28535","inReplyTo":"DBC73B3F-2703-4651-AADA-233A9CC38AFD@inf.fu-berlin.de","subject":"Re: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-30T21:38:41Z","receivedAt":"2011-09-30T21:38:41Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Sep 30, 2011 at 05:32:38PM +0200, Alexander Pepper wrote:\n\n> So git log with copy and rename detection on (--find-copies) tells me,\n> that the file StopClusterException.java is copied to\n> ClusterOperation.java. But If I ask git log for that specific file\n> with --follow git claims a copy from Immutable.java to\n> ClusterOperation.java!\n\nI think that --follow uses --find-copies-harder. Did you try:\n\n  git log --numstat --find-copies-harder dd4e90f9\n\n? Does it find Immutable.java as the source?\n\n-Peff\n"},{"id":"176686","messageId":"67B22035-4B90-4A68-8960-DDB58F640CD9@inf.fu-berlin.de","threadId":"28535","inReplyTo":"20110930213841.GA9384@sigill.intra.peff.net","subject":"Re: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'","fromName":"Alexander Pepper","fromEmail":"pepper@inf.fu-berlin.de","sentAt":"2011-10-02T15:10:26Z","receivedAt":"2011-10-02T15:10:26Z","isPatch":false,"sender":{"key":"pepper@inf.fu-berlin.de","avatar":null},"body":"\nAm 30.09.2011 um 23:38 schrieb Jeff King:\n\n> On Fri, Sep 30, 2011 at 05:32:38PM +0200, Alexander Pepper wrote:\n> \n>> So git log with copy and rename detection on (--find-copies) tells me,\n>> that the file StopClusterException.java is copied to\n>> ClusterOperation.java. But If I ask git log for that specific file\n>> with --follow git claims a copy from Immutable.java to\n>> ClusterOperation.java!\n> \n> I think that --follow uses --find-copies-harder. Did you try:\n> \n>  git log --numstat --find-copies-harder dd4e90f9\n> \n> ? Does it find Immutable.java as the source?\n> \n> -Peff\n\n\nUsing 'git log --numstat --find-copies-harder dd4e90f9' yields \"immutable.java\" as you expected:\n\n$ git log --numstat --find-copies-harder dd4e90f9\n[...]\n6       10      src/java/voldemort/annotations/concurrency/Immutable.java => contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java\n\nSo 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\"?\n\nGreetings from Berlin\nAlex\n\n-- \nAlexander Pepper\npepper@inf.fu-berlin.de\n"},{"id":"176687","messageId":"20111002152517.GA10353@sigill.intra.peff.net","threadId":"28535","inReplyTo":"67B22035-4B90-4A68-8960-DDB58F640CD9@inf.fu-berlin.de","subject":"Re: Bug?: 'git log --find-copies' doesn't match 'git log --follow <rev> -- path/to/file'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-10-02T15:25:17Z","receivedAt":"2011-10-02T15:25:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Oct 02, 2011 at 05:10:26PM +0200, Alexander Pepper wrote:\n\n> Using 'git log --numstat --find-copies-harder dd4e90f9' yields \"immutable.java\" as you expected:\n> \n> $ git log --numstat --find-copies-harder dd4e90f9\n> [...]\n> 6       10      src/java/voldemort/annotations/concurrency/Immutable.java => contrib/ec2-testing/src/java/voldemort/utils/ClusterOperation.java\n\nOK. That at least explains what's going on.\n\n> So is there a way to tell --follow to only use --find-copies instead\n> of --find-copies harder?\n\nNo, it's hard-coded.\n\n> And what is the advantage of using \"--find-copies-harder\" over \"--find-copies\"?\n\nIt finds more copies. The rename detection works like this:\n\n  --find-renames: for each newly-created file, consider any deleted\n                  files as possible sources\n\n  --find-copies: like above, but also consider any modified files as\n                 possible sources\n\n  --find-copies-harder: like above, but consider any file in the\n                        repository as a possible source\n\nSo in theory --find-copies-harder is the most accurate, but it is also\nthe most expensive. We can afford to do it for --follow since we're only\nconsidering a small subset of the possible destinations.\n\nSo git is saying that your immutable.java is actually a better match;\nit's just that we don't usually find it because it wasn't modified in\nthe same commit. Have you looked at the contents? Is it actually a\nbetter match, or is git wrong?\n\n-Peff\n"}]}