threads / discuss / 21089

git-diff/git-diff-files: Turn off copy-detection?

Subject: git-diff/git-diff-files: Turn off copy-detection?

## tl;dr

5 messages between Sep 29, 2009 and Sep 29, 2009.

replies: 4people: 4as markdown or json

Marius Storm-Olsen· Sep 29, 2009, 12:50 UTC · lore
Hi,

I'm trying to diff the header files between two version of a repo, to do an ABI review, but get too many diffs from 'similar copy', which makes the review hard. These are generally unrelated files, but due to large copyright header, and spaces, the actual changes are not large enough to be detected as new files. I'd therefore like to turn off copy detection completely, or at least set some kind of threshold before a file is considered a copy in the diff.

Doing a 'git diff origin/4.5..origin/4.6 -- src/corelib' gives me this excerpt:

diff --git origin/4.5/src/corelib/tools/qtimeline.h 
origin/4.6/src/corelib/animation/qabstractanimation.h
similarity index 58%
...
diff --git origin/4.5/src/corelib/kernel/qsystemsemaphore.h 
origin/4.6/src/corelib/animation/qanimationgroup.h
similarity index 63%
...
diff --git origin/4.5/src/corelib/kernel/qsystemsemaphore.h 
origin/4.6/src/corelib/animation/qparallelanimationgroup.h
similarity index 63%
...
diff --git origin/4.5/src/corelib/io/qresource_iterator_p.h 
origin/4.6/src/corelib/animation/qpauseanimation.h
similarity index 68%
...
diff --git origin/4.5/src/corelib/kernel/qsystemsemaphore.h 
origin/4.6/src/corelib/animation/qpropertyanimation.h
similarity index 60%
...
diff --git origin/4.5/src/corelib/kernel/qsystemsemaphore.h 
origin/4.6/src/corelib/animation/qsequentialanimationgroup.h
similarity index 55%
...
diff --git origin/4.5/src/corelib/animation/qvariantanimation.h 
origin/4.6/src/corelib/animation/qvariantanimation.h
new file mode 100644
...
diff --git origin/4.5/src/corelib/arch/qatomic_arch.h 
origin/4.6/src/corelib/arch/qatomic_arch.h
index 52ab101..548a5e9 100644

So, not even related. They should really had shown up as new files, 
IMO. (I guess git stores the creation of the file as a delta of the 
indicated 'copy', but in this case I don't care about that :)

Thanks!

--
.marius
Johannes Sixt· Sep 29, 2009, 13:40 UTC · re: Marius Storm-Olsen · lore

Re: git-diff/git-diff-files: Turn off copy-detection?

Marius Storm-Olsen schrieb:
Show 15 quoted lines
> I'm trying to diff the header files between two version of a repo, to do
> an ABI review, but get too many diffs from 'similar copy', which makes
> the review hard. These are generally unrelated files, but due to large
> copyright header, and spaces, the actual changes are not large enough to
> be detected as new files. I'd therefore like to turn off copy detection
> completely, or at least set some kind of threshold before a file is
> considered a copy in the diff.
> 
> Doing a 'git diff origin/4.5..origin/4.6 -- src/corelib' gives me this
> excerpt:
> 
> diff --git origin/4.5/src/corelib/tools/qtimeline.h
> origin/4.6/src/corelib/animation/qabstractanimation.h
> similarity index 58%
> ...

You must have the config variable diff.renames set. But I would not expect that this setting applies to 'git diff-files', only to 'git diff'.

You can also try 'git diff -C99 -M99' if you don't want to unset the config variable.

-- Hannes
Marius Storm-Olsen· Sep 29, 2009, 14:24 UTC · re: Johannes Sixt · lore

Re: git-diff/git-diff-files: Turn off copy-detection?

Johannes Sixt said the following on 29.09.2009 15:40:
Show 11 quoted lines
> Marius Storm-Olsen schrieb:
>> Doing a 'git diff origin/4.5..origin/4.6 -- src/corelib' gives me this
>> excerpt:
>>
>> diff --git origin/4.5/src/corelib/tools/qtimeline.h
>> origin/4.6/src/corelib/animation/qabstractanimation.h
>> similarity index 58%
>> ...
> 
> You must have the config variable diff.renames set. But I would not expect
> that this setting applies to 'git diff-files', only to 'git diff'.

$ git config diff.renames copies

That's it, thanks! Strange that nothing in the git-diff documentation pointed me in this direction? Obviously I didn't connect the dots between 'copy' and 'renames' either..

> You can also try 'git diff -C99 -M99' if you don't want to unset the
> config variable.
Thanks, I'll add that to my review script. Much appreciated!

-- .marius

Miklos Vajna· Sep 29, 2009, 15:05 UTC · re: Marius Storm-Olsen · lore

Re: git-diff/git-diff-files: Turn off copy-detection?

On Tue, Sep 29, 2009 at 04:24:59PM +0200, Marius Storm-Olsen <marius@storm-olsen.com> wrote:
Show 6 quoted lines
> $ git config diff.renames
> copies
> 
> That's it, thanks! Strange that nothing in the git-diff documentation 
> pointed me in this direction? Obviously I didn't connect the dots 
> between 'copy' and 'renames' either..
See man git-config. :)
Miklos Vajna· Sep 29, 2009, 13:42 UTC · re: Marius Storm-Olsen · lore

Re: git-diff/git-diff-files: Turn off copy-detection?

On Tue, Sep 29, 2009 at 02:50:14PM +0200, Marius Storm-Olsen <mstormo@gmail.com> wrote:
> So, not even related. They should really had shown up as new files, 
> IMO. (I guess git stores the creation of the file as a delta of the 
> indicated 'copy', but in this case I don't care about that :)

No, it does not (as long as we are not talking about packfiles). AFAIK copy detection is disabled by default, so probably you have a setting that enables it for you and you forgot about it. Are you sure you don't have any settings like diff.renames = copies?

← back to recent threads