Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Shawn Pearce <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: Bug in merge-recursive in virtual commit corner case
Date: Thu, 07 Dec 2006 01:13:54 -0800	[thread overview]
Message-ID: <7vmz60ukz1.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20061207083531.GA22701@spearce.org> (Shawn Pearce's message of "Thu, 7 Dec 2006 03:35:31 -0500")

Shawn Pearce <spearce@spearce.org> writes:

> I found the above error message in tree-diff.c's diff_tree_sha1
> function.  I threw in debugging and found that the new tree was
> the root tree of one branch and the base was the root tree of some
> other revision.
>
> Apparently the empty tree is being created in merge-recursive.c:
>
>    1219     if (merged_common_ancestors == NULL) {
>    1220         /* if there is no common ancestor, make an empty tree */
>    1221         struct tree *tree = xcalloc(1, sizeof(struct tree));
>    1222
>    1223         tree->object.parsed = 1;
>    1224         tree->object.type = OBJ_TREE;
>    1225         hash_sha1_file(NULL, 0, tree_type, tree->object.sha1);
>    1226         merged_common_ancestors = make_virtual_commit(tree, "ancestor");
>    1227     }
>
> So basically this code crashes if its ever used in a repository
> that hasn't had a need for the empty tree before.  :-(

I hit the same issue when I integrated Johannes's in-core merge;
I originally used hash_sha1_file() but that results in objects
that are supposed to be in the virtual parent unreadable when
merging the real children.  The key is to use write_sha1_file()
to actually create the needed objects, and trust later prune to
remove them.

Replace it with write_sha1_file() and you should be fine, I
think.

  reply	other threads:[~2006-12-07  9:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-07  8:35 Bug in merge-recursive in virtual commit corner case Shawn Pearce
2006-12-07  9:13 ` Junio C Hamano [this message]
2006-12-07 15:38 ` Johannes Schindelin
2006-12-07 19:24   ` Shawn Pearce
2006-12-08  3:03     ` Johannes Schindelin
2006-12-08  6:01     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmz60ukz1.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox