Re: Segfault with merge-tree on multiple Git versions
- From
Jeff King <peff@peff.net>
- Date
- Mar 27, 2013, 20:01 UTC
- Message-ID
- <20130327200113.GC26380@sigill.intra.peff.net>
- In-Reply-To
- <20130327194521.GQ2286@serenity.lan>
On Wed, Mar 27, 2013 at 07:45:21PM +0000, John Keeping wrote:
Show 27 quoted lines
> On Wed, Mar 27, 2013 at 02:16:24PM -0500, Jed Brown wrote: > > Charlie Smurthwaite <charlie@atechmedia.com> writes: > > > > > Yes, I would need to be able to do this on a bare repo for my use case. > > > > And if it's on the server, you don't want this to be observable, so > > you don't want HEAD to move around. I don't know a better way than: > > > > $ git clone --shared -b upstream-branch bare-repo.git /tmp/merge-repo > > $ cd /tmp/merge-repo > > $ git pull URL incoming-branch > > > > Cloning with --shared just writes a path into .git/objects/info/alternatives > > and it doesn't need to be on the same file system (unlike --local). > > > > Since 'git merge-tree' just works with trees, it has less information > > than 'git merge'. > > You could use a temporary index and do something like: > > rm -f TMP_INDEX > GIT_INDEX_FILE=TMP_INDEX > export GIT_INDEX_FILE > git read-tree -m $base $ours $theirs && > git merge-index git-merge-one-file -a > > then inspect that with "git diff-index --cached $ours".
That is precisely how we do it at GitHub. You probably want to add in "--aggressive" to your read-tree to cover a few more simple cases. If there are conflicts, we just bail and say "this can't be merged", and expect the user to do it themselves using git.
-Peff