Re: Merging limitations after directory renames -- interesting test repo
flat view
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:50:36
On Fri, Feb 18, 2011 at 3:27 PM, Linus Torvalds [off-list ref] wrote:
We've had stupid bugs in the "diffcore_count_changes()" logic before. It's just that they're _usually_ hidden by overwhelming common code. In fact, the attached patch improves things a bit.
There's a secondary problem too, which is illustrated by this:
[torvalds@i5 etherpad]$ git diff --summary -M30 $BASE.. | grep
m0024_statistics_table.js
copy {trunk/etherpad =>
etherpad}/src/etherpad/db_migrations/m0024_statistics_table.js (100%)
rename trunk/etherpad/src/etherpad/db_migrations/m0024_statistics_table.js
=> etherpad/src/etherpad/db_migrations/m0040_create_plugin_tables.js
(52%)
which also ends up terminally confusing the merge. It sees that dual
source of m0024_statistics_table.js and just gets really really
confused.
And the bug is that we didn't even ask for copy detection! This just
confuses merging more.
Attached is the ugliest patch ever. I'm in no way implying this should
ever be accepted, with
- that crazy-ugly static variable to pass in the copy state to the
'for_each_hash()' callback
- that really ugly "if (detect_rename == DIFF_DETECT_COPY)" with
broken indentation just to get rid of the copy-checking phase.
So please consider the attached patch just a "look, guys, this is
wrong, and here's the ugliest hack you've ever seen to fix it".
Anyway, with this, I can at least do
git merge -Xrename-threshold=30 origin/pg
and while it fails miserably, the failures are now no longer "totally
obviously a git bug". Now it has real rename-rename conflicts like
CONFLICT (rename/rename): Rename
"trunk/etherpad/src/static/crossdomain.xml"->"etherpad/src/static/crossdomain.xml"
in branch "HEAD"
rename
"trunk/etherpad/src/static/crossdomain.xml"->"etherpad/src/static/crossdomain.xml.in"
in "origin/pg"
which really _is_ a conflict that needs user input.
Now, I didn't check that they are *all* of this valid kind, but most
of them really are. The directories are:
(HEAD): etherpad/src/themes/default/templates
(origin/pg): etherpad/src/templates
so you'd need to fix that up.
Whatever. It's still a nasty merge, but at least git seems to do a
much better job. That "-Xrename-threshold=30" thing is a total hack,
but it's a valid way to say "ok, git didn't find some renames I want
it to, so let's see if I can force it to do a less critical search".
Linus Attachments
- patch.diff [text/x-patch] 2231 bytes · preview