git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Segfault with merge-tree on multiple Git versions

From
John Keeping <john@keeping.me.uk>
Date
Mar 27, 2013, 15:58 UTC
Message-ID
<20130327155850.GN2286@serenity.lan>
In-Reply-To
<87boa47saw.fsf@linux-k42r.v.cablecom.net>
On Wed, Mar 27, 2013 at 04:53:27PM +0100, thomas wrote:
Show 43 quoted lines
> Charlie Smurthwaite <charlie@atechmedia.com> writes:
> 
> > I am experiencing a segmentation fault in various versions of Git using
> > different repositories. Specifically, I have reproduced it using a
> > public repo and the latest stable Git version. Other repos trigger the
> > error on different versions.
> >
> > Full info can be found below. Thanks,
> >
> > Charlie
> >
> >
> > Test repository:
> > https://github.com/atech/mail
> >
> > Test Command
> > git merge-tree 26bb22a052fef9f74063afd4fc6fc11fe200b19f
> > 8d6bdf012941d876b2279994e02f1bb0d5c26e7d
> > d5ef97ac407d945f231cd7c8fb1cfe48b3a12083
> 
> I happened to walk past on IRC and found I could easily reproduce it, so
> I bisected:
> 
>   35ffe7583108ab236dcf81226690388491d9962f is the first bad commit
>   commit 35ffe7583108ab236dcf81226690388491d9962f
>   Author: Junio C Hamano <gitster@pobox.com>
>   Date:   Thu Dec 13 15:51:29 2012 -0800
> 
>       merge-tree: fix d/f conflicts
>       
>       The previous commit documented two known breakages revolving around
>       a case where one side flips a tree into a blob (or vice versa),
>       where the original code simply gets confused and feeds a mixture of
>       trees and blobs into either the recursive merge-tree (and recursing
>       into the blob will fail) or three-way merge (and merging tree contents
>       together with blobs will fail).
>       
>       Fix it by feeding trees (and only trees) into the recursive
>       merge-tree machinery and blobs (and only blobs) into the three-way
>       content level merge machinery separately; when this happens, the
>       entire merge has to be marked as conflicting at the structure level.
>       
>       Signed-off-by: Junio C Hamano <gitster@pobox.com>
Looks like a simple typo in merge-tree.c::unresolved:

-- >8 -- merge-tree: fix typo in merge-tree.c::unresolved

When calculating whether there is a d/f conflict, the calculation of whether both sides are directories generates an incorrect references mask because it does not use the loop index to set the correct bit. Fix this typo.

Signed-off-by: John Keeping <john@keeping.me.uk>
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index e0d0b7d..bc912e3 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -245,7 +245,7 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
 	unsigned dirmask = 0, mask = 0;
 
 	for (i = 0; i < 3; i++) {
-		mask |= (1 << 1);
+		mask |= (1 << i);
 		if (n[i].mode && S_ISDIR(n[i].mode))
 			dirmask |= (1 << i);
 	}
Previous: thomasNext: Thomas Rast
Message 3 of 15 in “Segfault with merge-tree on multiple Git versions”
  1. Charlie SmurthwaiteMar 27, 2013
  2. thomasMar 27, 2013
  3. John KeepingMar 27, 2013
  4. Thomas RastMar 27, 2013
  5. Junio C HamanoMar 27, 2013
  6. Junio C HamanoMar 27, 2013
  7. Charlie SmurthwaiteMar 27, 2013
  8. Charlie SmurthwaiteMar 27, 2013
  9. Jed BrownMar 27, 2013
  10. Charlie SmurthwaiteMar 27, 2013
  11. Jed BrownMar 27, 2013
  12. John KeepingMar 27, 2013
  13. Jeff KingMar 27, 2013
  14. Charlie SmurthwaiteMar 27, 2013
  15. Junio C HamanoMar 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.