From: Petr Baudis Date: Fri, 11 Nov 2005 11:45:11 GMT Subject: Re: Strange merge conflicts against earlier merge. Message-ID: <20051111114511.GQ30496@pasky.or.cz> In-Reply-To: <20051111075257.GA4765@c165.ib.student.liu.se> Dear diary, on Fri, Nov 11, 2005 at 08:52:57AM CET, I got a letter where Fredrik Kuivinen said that... > On Thu, Nov 10, 2005 at 01:38:35PM +1300, Martin Langhoff wrote: > > We are working with a series of closely related heads, and merging > > among them. I am sometimes finding merge conflicts that I don't think > > I should be seeing. Assuming two branches, 'local' and 'remote', where > > local has with remote before (*), and I have no conflicting changes in > > local... > > > > 1 - pull and merge from remote. The merge touches file A, B and C > > 2 - on local, develop on unrelated files O,P,Q, commit > > 3 - pull and merge from remote. The merge touches file B, C and D. I > > am sometimes seeing conflicts on file B and C, which was never touched > > on local. > > > > * - In the case i have, the ancestry before the merge is a bit > > convoluted. AFAIK, this shouldn't affect us going forward. Both > > branches have a common ancestor, though, and are now merging often > > from remote to local. > > > > We are using cogito for this, although on step 3 I have also tested > > with git-merge.sh and I get the same result. It could still be a > > problem related to how the merge on step 1 is recording the merge. > > > > For an example, clone > > http://locke.catalyst.net.nz/git/moodle.git#mdl-artena-tairawhiti and > > register also the > > http://locke.catalyst.net.nz/git/moodle.git#mdl-local branch. Create > > two heads: > > > > master: 214e6374d49e6d014f0ba6f159d585a3fe468909 > > remote: 05059be73c9e09e22b98bc796be35c595e551ed6 > > > > On git-merge 'testing merge' master remote you'll see conflicts over > > mod/quiz/editlib.php -- doing the same with cg-merge gets an > > additional conflict on mod/quiz/export.php. Neither of those files > > were ever modified on local -- however, both merges brought in changes > > to the same lines of code. > > > > I suspect this is because the merge itself is being considered a > > commit on the local branch. Fair enough -- git has no way of ensuring > > that I haven't slipped in a few changes of mine in the merge. OTOH, > > it's pretty unexpected to see this on files that are not one char > > different from the 'remote' branch. Am I doing something wrong? > > > > This merge has two common ancestors, > > $ git-merge-base --all master remote > 3b12fc6420c26a6556c2d806fca79dd96e8e22b9 > 2163a9076d9515f00494ba9df7dbc85c9804790f > > This may explain the results you get with cg-merge, as that script > seems to use 'git-merge-base' without the '--all' flag. Hmm. So what should I do with that? :-) I wondered about adding multi-base merge support to Cogito, but it seems to be a bit funny, and totally undocumented. Especially, is it right that I would end up with _four_ stages in case of two-base "three"-way merge? That would mean complete rewrite of the one-file merger, right? And it seems git-merge-index would overflow and crash. :-) I guess I really don't want to do that, but instead choose one of the bases. Hmm. Well, I suppose it's as good as anything to leave this decision on the user. Kind of: if [ $(wc -l merge-bases) -ge 1 ]; then echo "Multiple merge bases, please select one by the -b parameter:" >&2 cat merge-bases echo -n "The most conservative base (but likely a lot of conflicts):" >&2 while true; do git-merge-base --all $(cat merge-bases) >merge-bases~ mv merge-bases~ merge-bases [ $(wc -l merge-bases) -eq 1 ] && break done cat merge-bases exit 1 fi Does core GIT have support for multibase merges, except for the recursive merge strategy? How do you do it? -- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ VI has two modes: the one in which it beeps and the one in which it doesn't.