# Re: Intensive rename detection

11 messages from 2008-11-04 to 2008-11-05. Participants: Andrew Arnott, Junio C Hamano, Linus Torvalds, Jeff King, Björn Steinbrink.
Thread: https://gitlist.dev/t/16160

## Andrew Arnott, 2008-11-04 01:18

Subject: Re: Intensive rename detection
Message-ID: <216e54900811031718o4cc81294sc0c32be1e71b9372@mail.gmail.com>
URL: https://gitlist.dev/e/216e54900811031718o4cc81294sc0c32be1e71b9372%40mail.gmail.com
In-Reply-To: <216e54900811031717j70669868p3c7503357ceb5138@mail.gmail.com>

```
I'm refactoring a library including renaming both files and
directories.  A few lines of each file are also changed, but they are
substantially unchanged in content.  I've done a git add to put all my
changes into the index, but a git status shows that git only detected
a few of the renames... most of them are delete-add operations.  Is
there anything I can do to help git recognize the rename so that
history is preserved across this commit?

Thanks.

```

## Junio C Hamano, 2008-11-04 01:39

Subject: Re: Intensive rename detection
Message-ID: <7vy700s215.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy700s215.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <216e54900811031718o4cc81294sc0c32be1e71b9372@mail.gmail.com>

```
"Andrew Arnott" <andrewarnott@gmail.com> writes:

> I'm refactoring a library including renaming both files and
> directories.  A few lines of each file are also changed, but they are
> substantially unchanged in content.  I've done a git add to put all my
> changes into the index, but a git status shows that git only detected
> a few of the renames... most of them are delete-add operations.  Is
> there anything I can do to help git recognize the rename so that
> history is preserved across this commit?

There is no need to do anything at commit time.

After making the commit, you can look at it with lower similarity
threashold, e.g.

	git show --stat -M1 HEAD

The default behaviour IIRC corresponds to -M5 (that is 50%).

```

## Linus Torvalds, 2008-11-04 04:22

Subject: Re: Intensive rename detection
Message-ID: <alpine.LFD.2.00.0811032021210.3419@nehalem.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.2.00.0811032021210.3419%40nehalem.linux-foundation.org
In-Reply-To: <216e54900811031718o4cc81294sc0c32be1e71b9372@mail.gmail.com>

```


On Mon, 3 Nov 2008, Andrew Arnott wrote:
>
> I'm refactoring a library including renaming both files and
> directories.  A few lines of each file are also changed, but they are
> substantially unchanged in content.  I've done a git add to put all my
> changes into the index, but a git status shows that git only detected
> a few of the renames... most of them are delete-add operations.  Is
> there anything I can do to help git recognize the rename so that
> history is preserved across this commit?

How many renames do you have? Modern versions of git will do any number of 
exact renames, but the (rather expensive) inexact rename detection has a 
default limit of something fairly small.

You could try adding

	[diff]
		renamelimit=0

to your ~/.gitconfig file. It can be quite expensive though.

			Linus

```

## Linus Torvalds, 2008-11-04 04:23

Subject: Re: Intensive rename detection
Message-ID: <alpine.LFD.2.00.0811032022580.3419@nehalem.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.2.00.0811032022580.3419%40nehalem.linux-foundation.org
In-Reply-To: <alpine.LFD.2.00.0811032021210.3419@nehalem.linux-foundation.org>

```


On Mon, 3 Nov 2008, Linus Torvalds wrote:
> 
> You could try adding
> 
> 	[diff]
> 		renamelimit=0
> 
> to your ~/.gitconfig file. It can be quite expensive though.

Oh, and obviously Junio is right that some create/deletes won't be seen as 
renames anyway, if you changed enough of the file and/or if the files in 
question are so small that they end up being considered rewrites just 
because of that.

		Linus

```

## Jeff King, 2008-11-04 04:31

Subject: Re: Intensive rename detection
Message-ID: <20081104043133.GB31276@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20081104043133.GB31276%40coredump.intra.peff.net
In-Reply-To: <alpine.LFD.2.00.0811032021210.3419@nehalem.linux-foundation.org>

```
On Mon, Nov 03, 2008 at 08:22:34PM -0800, Linus Torvalds wrote:

> How many renames do you have? Modern versions of git will do any number of 
> exact renames, but the (rather expensive) inexact rename detection has a 
> default limit of something fairly small.

I was about to say "git should have complained about turning off the
requested rename detection", but I forgot that we silenced that warning
except for merges.

Maybe it makes sense for "status" or a single "diff" (but definitely not
"log", where it isn't even clear which diff caused it!). I dunno. I find
it clutter for anything except a merge, but if that is in fact what is
happening here, it might have produced one slightly less confused user.

-Peff

```

## Andrew Arnott, 2008-11-04 05:19

Subject: Re: Intensive rename detection
Message-ID: <216e54900811032119h4cb51327v2d85712acc444185@mail.gmail.com>
URL: https://gitlist.dev/e/216e54900811032119h4cb51327v2d85712acc444185%40mail.gmail.com
In-Reply-To: <216e54900811032107p159e98ecn8958f0a78efde8f2@mail.gmail.com>

```
Awesome.  Per Linus' tip, I just noticed at the top of a long list of
messages git said:
warning: too many files, skipping inexact rename detection

So I added the config file change, and that did the trick.  Thanks, everyone!

Here's a related but slightly different question: I've been stashing
and unstashing in the midst of all these renames and refactoring, and
now I'm left with some files listed in git status 3 times.  I
understand why this is, but I don't know the best way to proceed.  Git
is telling me:

$ git status | grep MessageBase
src/DotNetOAuth/Messages/MessageBase.cs: needs merge
src/DotNetOAuth/OAuth/Messages/MessageBase.cs: needs merge
src/DotNetOpenAuth/Messages/MessageBase.cs: needs merge
#       unmerged:   src/DotNetOAuth/Messages/MessageBase.cs
#       unmerged:   src/DotNetOAuth/OAuth/Messages/MessageBase.cs
#       unmerged:   src/DotNetOpenAuth/Messages/MessageBase.cs

I want to end up with MessageBase.cs in
src/DotNetOpenAuth/OAuth/Messages/MessageBase.cs, which ironically is
none of these three.  And the couple of lines that changed in the file
need to be merged.  Only two of these listed files exist on disk.  How
can I best leverage git to merge the two files on disk while moving it
to a new location?

> On Mon, Nov 3, 2008 at 8:22 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>>
>>
>> On Mon, 3 Nov 2008, Andrew Arnott wrote:
>> >
>> > I'm refactoring a library including renaming both files and
>> > directories.  A few lines of each file are also changed, but they are
>> > substantially unchanged in content.  I've done a git add to put all my
>> > changes into the index, but a git status shows that git only detected
>> > a few of the renames... most of them are delete-add operations.  Is
>> > there anything I can do to help git recognize the rename so that
>> > history is preserved across this commit?
>>
>> How many renames do you have? Modern versions of git will do any number of
>> exact renames, but the (rather expensive) inexact rename detection has a
>> default limit of something fairly small.
>>
>> You could try adding
>>
>>        [diff]
>>                renamelimit=0
>>
>> to your ~/.gitconfig file. It can be quite expensive though.
>>
>>                        Linus
>

```

## Andrew Arnott, 2008-11-04 06:02

Subject: Re: Intensive rename detection
Message-ID: <216e54900811032202h5c82e3a9j30100e5b82f6a16a@mail.gmail.com>
URL: https://gitlist.dev/e/216e54900811032202h5c82e3a9j30100e5b82f6a16a%40mail.gmail.com
In-Reply-To: <216e54900811032119h4cb51327v2d85712acc444185@mail.gmail.com>

```
Hmmm.... actually on second run I am still getting the too many files
warning.  I put the [diff] section in a ~/.gitconfig file, a
.gitconfig file in the root of my repo, and in the .git/config file,
but none of them seem to get rid of the message.

I'm running git version 1.5.5.1015.g9d258

Is that too old for this removal of a file rename limit?

On Mon, Nov 3, 2008 at 9:19 PM, Andrew Arnott <andrewarnott@gmail.com> wrote:
> Awesome.  Per Linus' tip, I just noticed at the top of a long list of
> messages git said:
> warning: too many files, skipping inexact rename detection
>
> So I added the config file change, and that did the trick.  Thanks, everyone!
>
> Here's a related but slightly different question: I've been stashing
> and unstashing in the midst of all these renames and refactoring, and
> now I'm left with some files listed in git status 3 times.  I
> understand why this is, but I don't know the best way to proceed.  Git
> is telling me:
>
> $ git status | grep MessageBase
> src/DotNetOAuth/Messages/MessageBase.cs: needs merge
> src/DotNetOAuth/OAuth/Messages/MessageBase.cs: needs merge
> src/DotNetOpenAuth/Messages/MessageBase.cs: needs merge
> #       unmerged:   src/DotNetOAuth/Messages/MessageBase.cs
> #       unmerged:   src/DotNetOAuth/OAuth/Messages/MessageBase.cs
> #       unmerged:   src/DotNetOpenAuth/Messages/MessageBase.cs
>
> I want to end up with MessageBase.cs in
> src/DotNetOpenAuth/OAuth/Messages/MessageBase.cs, which ironically is
> none of these three.  And the couple of lines that changed in the file
> need to be merged.  Only two of these listed files exist on disk.  How
> can I best leverage git to merge the two files on disk while moving it
> to a new location?
>
>> On Mon, Nov 3, 2008 at 8:22 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>>>
>>>
>>> On Mon, 3 Nov 2008, Andrew Arnott wrote:
>>> >
>>> > I'm refactoring a library including renaming both files and
>>> > directories.  A few lines of each file are also changed, but they are
>>> > substantially unchanged in content.  I've done a git add to put all my
>>> > changes into the index, but a git status shows that git only detected
>>> > a few of the renames... most of them are delete-add operations.  Is
>>> > there anything I can do to help git recognize the rename so that
>>> > history is preserved across this commit?
>>>
>>> How many renames do you have? Modern versions of git will do any number of
>>> exact renames, but the (rather expensive) inexact rename detection has a
>>> default limit of something fairly small.
>>>
>>> You could try adding
>>>
>>>        [diff]
>>>                renamelimit=0
>>>
>>> to your ~/.gitconfig file. It can be quite expensive though.
>>>
>>>                        Linus
>>
>

```

## Jeff King, 2008-11-04 06:16

Subject: Re: Intensive rename detection
Message-ID: <20081104061647.GA18297@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20081104061647.GA18297%40coredump.intra.peff.net
In-Reply-To: <216e54900811032202h5c82e3a9j30100e5b82f6a16a@mail.gmail.com>

```
On Mon, Nov 03, 2008 at 10:02:37PM -0800, Andrew Arnott wrote:

> Hmmm.... actually on second run I am still getting the too many files
> warning.  I put the [diff] section in a ~/.gitconfig file, a
> .gitconfig file in the root of my repo, and in the .git/config file,
> but none of them seem to get rid of the message.

Where are you getting the warning? On "git status"?

If so, then this is an instance of the problem I mentioned here:

  [PATCH v3 7/8] wt-status: load diff ui config
  20081026044935.GG21047@coredump.intra.peff.net

(sorry, I would link to gmane, but it seems to be down at the moment).
Junio, maybe it is worth applying after all (we could also do just the
diff "basic" config instead).

-Peff

```

## Andrew Arnott, 2008-11-04 06:36

Subject: Re: Intensive rename detection
Message-ID: <216e54900811032236l5ae4bde5v16ab6519962e428f@mail.gmail.com>
URL: https://gitlist.dev/e/216e54900811032236l5ae4bde5v16ab6519962e428f%40mail.gmail.com
In-Reply-To: <20081104061647.GA18297@coredump.intra.peff.net>

```
Yes, on git status.  I'm afraid I don't know how to look up the
reference you gave.

On Mon, Nov 3, 2008 at 10:16 PM, Jeff King <peff@peff.net> wrote:
> On Mon, Nov 03, 2008 at 10:02:37PM -0800, Andrew Arnott wrote:
>
>> Hmmm.... actually on second run I am still getting the too many files
>> warning.  I put the [diff] section in a ~/.gitconfig file, a
>> .gitconfig file in the root of my repo, and in the .git/config file,
>> but none of them seem to get rid of the message.
>
> Where are you getting the warning? On "git status"?
>
> If so, then this is an instance of the problem I mentioned here:
>
>  [PATCH v3 7/8] wt-status: load diff ui config
>  20081026044935.GG21047@coredump.intra.peff.net
>
> (sorry, I would link to gmane, but it seems to be down at the moment).
> Junio, maybe it is worth applying after all (we could also do just the
> diff "basic" config instead).
>
> -Peff
>

```

## Björn Steinbrink, 2008-11-04 10:47

Subject: Re: Intensive rename detection
Message-ID: <20081104104738.GD21251@atjola.homenet>
URL: https://gitlist.dev/e/20081104104738.GD21251%40atjola.homenet
In-Reply-To: <216e54900811032236l5ae4bde5v16ab6519962e428f@mail.gmail.com>

```
On 2008.11.03 22:36:42 -0800, Andrew Arnott wrote:
> On Mon, Nov 3, 2008 at 10:16 PM, Jeff King <peff@peff.net> wrote:
> > On Mon, Nov 03, 2008 at 10:02:37PM -0800, Andrew Arnott wrote:
> >
> >> Hmmm.... actually on second run I am still getting the too many files
> >> warning.  I put the [diff] section in a ~/.gitconfig file, a
> >> .gitconfig file in the root of my repo, and in the .git/config file,
> >> but none of them seem to get rid of the message.
> >
> > Where are you getting the warning? On "git status"?
> >
> > If so, then this is an instance of the problem I mentioned here:
> >
> >  [PATCH v3 7/8] wt-status: load diff ui config
> >  20081026044935.GG21047@coredump.intra.peff.net
>
> Yes, on git status.  I'm afraid I don't know how to look up the
> reference you gave.

http://marc.info/?l=git&m=122499658810367&w=2

Björn

```

## Jeff King, 2008-11-05 03:22

Subject: Re: Intensive rename detection
Message-ID: <20081105032220.GE20907@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20081105032220.GE20907%40coredump.intra.peff.net
In-Reply-To: <216e54900811032236l5ae4bde5v16ab6519962e428f@mail.gmail.com>

```
On Mon, Nov 03, 2008 at 10:36:42PM -0800, Andrew Arnott wrote:

> Yes, on git status.  I'm afraid I don't know how to look up the
> reference you gave.

Sorry, gmane is back up, so the link is:

  http://article.gmane.org/gmane.comp.version-control.git/99147

With that patch, and this one on top, "git status" should respect your
rename limits (though I haven't tested it).

---
diff --git a/wt-status.c b/wt-status.c
index c3a9cab..0b92ac3 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -214,7 +214,6 @@ static void wt_status_print_updated(struct wt_status *s)
 	rev.diffopt.format_callback = wt_status_print_updated_cb;
 	rev.diffopt.format_callback_data = s;
 	rev.diffopt.detect_rename = 1;
-	rev.diffopt.rename_limit = 200;
 	rev.diffopt.break_opt = 0;
 	run_diff_index(&rev, 1);
 }

-Peff

```
