Re: detecting rename->commit->modify->commit
- From
Jeff King <peff@peff.net>
- Date
- May 1, 2008, 15:20 UTC
- Message-ID
- <20080501152035.GB11145@sigill.intra.peff.net>
- In-Reply-To
- <4819DCF1.7090504@tikalk.com>
On Thu, May 01, 2008 at 06:08:33PM +0300, Ittay Dror wrote:
> But it doesn't work across directories :-(.
Yes, it does.
Show 16 quoted lines
> Try: > >mkdir foo > >echo "hello" > foo/A > >git add foo/A > >git commit -m 'foo/A' > >mkdir bar > >git mv foo/A bar > >git commit -m 'bar/A' > >echo "world" >> bar/A > >git add bar/A > >git commit -m 'bar/A world' > >git diff HEAD^^..HEAD^ | cat > diff --git a/foo/A b/bar/A > similarity index 100% > rename from foo/A > rename to bar/A
See, it just worked across directories.
Show 16 quoted lines
> > git diff HEAD^^.. | cat > diff --git a/bar/A b/bar/A > new file mode 100644 > index 0000000..94954ab > --- /dev/null > +++ b/bar/A > @@ -0,0 +1,2 @@ > +hello > +world > diff --git a/foo/A b/foo/A > deleted file mode 100644 > index ce01362..0000000 > --- a/foo/A > +++ /dev/null > @@ -1 +0,0 @@ > -hello
Of course it doesn't work here. You have two files, one containing "hello\n" and one containing "hello\nworld\n". Their similarity is 50%, which is not enough to consider it a rename. And I would argue that's reasonable, since the files have only one line in common. The problem is that you are using a toy example (which is why my example used /usr/share/dict/words, which has enough content to definitively call it a rename).
...
Hmm, looking at the code, though, 50% is supposed to be the default minimum. So there might actually be a bug.
-Peff