Anonymous committed 88f8f0a

[PATCH] Enable and fix support for base less merges.

Let the merge strategies handle the base less case if they are able to
do it. It also fixes to die if no common ancestors
exists, instead of doing the wrong thing. Furthermore, it contains a
small independent fix for and a fix for a base less code
path in

With this it's possible to use
git merge -s recursive 'merge message' A B
to do a base less merge of A and B.

[jc: Thanks Fredrik for fixing the brown-paper-bag in git-merge.
I fixed a small typo in git-merge-resolve fix; 'test' equality
check is spelled with single equal sign -- C-style double equal
sign is bashism.]

Signed-off-by: Fredrik Kuivinen <>
Signed-off-by: Junio C Hamano <>

Comments (0)

Files changed (3)

 	exit 2 ;;
+# Give up if this is a baseless merge.
+if test '' = "$bases"
+	exit 2
 git-update-index --refresh 2>/dev/null
 git-read-tree -u -m $bases $head $remotes || exit 2
 echo "Trying simple merge."
 savestate() {
 	# Stash away any local modifications.
 	git-diff-index -r -z --name-only $head |
-	cpio -0 -o >"$GIR_DIR/MERGE_SAVE"
+	cpio -0 -o >"$GIT_DIR/MERGE_SAVE"
 restorestate() {
 case "$#,$common" in
-	die "Unable to find common commit between $head_arg and $*"
+	# No common ancestors found. We need a real merge.
 	# If head can reach all the merge then we are up to date.

 # Write the empty tree to the object database and return its SHA1
 def writeEmptyTree():
-    tmpIndex = os.environ['GIT_DIR'] + '/merge-tmp-index'
+    tmpIndex = os.environ.get('GIT_DIR', '.git') + '/merge-tmp-index'
     def delTmpIndex():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.