git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "R. Andrew Ohana" <andrew.ohana@gmail.com>
To: git@vger.kernel.org
Cc: "R. Andrew Ohana" <andrew.ohana@gmail.com>
Subject: [PATCH] octopus: fallback on empty tree for ancestor
Date: Wed, 19 Jun 2013 17:27:14 -0700	[thread overview]
Message-ID: <1371688034-12145-1-git-send-email-andrew.ohana@gmail.com> (raw)
In-Reply-To: <andrew.ohana@gmail.com>

From: "R. Andrew Ohana" <andrew.ohana@gmail.com>

This is preferable to just aborting when no
common ancestor is found since it handles merges
of intersecting branches.

This is incredibly useful functionality when
consolidating multiple repositories (potentially
after using filter-branch to fix paths).

See http://stackoverflow.com/questions/10874149.

Signed-off-by: R. Andrew Ohana <andrew.ohana@gmail.com>
---
 git-merge-octopus.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index 8643f74..582ae69 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -48,6 +48,7 @@ MRC=$(git rev-parse --verify -q $head)
 MRT=$(git write-tree)
 NON_FF_MERGE=0
 OCTOPUS_FAILURE=0
+EMPTY_TREE=$(git hash-object -t tree /dev/null)
 for SHA1 in $remotes
 do
 	case "$OCTOPUS_FAILURE" in
@@ -67,7 +68,9 @@ do
 		eval pretty_name=\${GITHEAD_$SHA1_UP:-$pretty_name}
 	fi
 	common=$(git merge-base --all $SHA1 $MRC) ||
-		die "Unable to find common commit with $pretty_name"
+		# Try with an empty tree if no common ancestor was
+		# found, since it is common to all trees.
+		common=$EMPTY_TREE
 
 	case "$LF$common$LF" in
 	*"$LF$SHA1$LF"*)
-- 
1.8.2.1

                 reply	other threads:[~2013-06-20  0:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1371688034-12145-1-git-send-email-andrew.ohana@gmail.com \
    --to=andrew.ohana@gmail.com \
    --cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).