Skip to content

Commit

Permalink
[PATCH] Enable and fix support for base less merges.
Browse files Browse the repository at this point in the history
Let the merge strategies handle the base less case if they are able to
do it. It also fixes git-resolve.sh to die if no common ancestors
exists, instead of doing the wrong thing. Furthermore, it contains a
small independent fix for git-merge.sh and a fix for a base less code
path in gitMergeCommon.py.

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 <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Fredrik Kuivinen authored and Junio C Hamano committed Oct 3, 2005
1 parent 99a19b4 commit 88f8f0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions git-merge-resolve.sh
Expand Up @@ -31,6 +31,12 @@ case "$remotes" in
exit 2 ;;
esac

# Give up if this is a baseless merge.
if test '' = "$bases"
then
exit 2
fi

git-update-index --refresh 2>/dev/null
git-read-tree -u -m $bases $head $remotes || exit 2
echo "Trying simple merge."
Expand Down
4 changes: 2 additions & 2 deletions git-merge.sh
Expand Up @@ -26,7 +26,7 @@ dropsave() {
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() {
Expand Down Expand Up @@ -103,7 +103,7 @@ echo "$head" >"$GIT_DIR/ORIG_HEAD"

case "$#,$common" in
*,'')
die "Unable to find common commit between $head_arg and $*"
# No common ancestors found. We need a real merge.
;;
1,"$1")
# If head can reach all the merge then we are up to date.
Expand Down
2 changes: 1 addition & 1 deletion gitMergeCommon.py
Expand Up @@ -213,7 +213,7 @@ def buildGraph(heads):

# 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():
try:
os.unlink(tmpIndex)
Expand Down

0 comments on commit 88f8f0a

Please sign in to comment.