Skip to content

Commit

Permalink
git-smerge: Work in progress on a slightly smarter merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiegley committed Mar 3, 2011
1 parent 401851c commit b1f276e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions git-smerge
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

current=$(git symbolic-ref HEAD | sed 's%refs/heads/%%')
branch=$1

if ! git merge $branch; then
echo GIT-SMERGE: Simple merge with $branch failed, attempting rebase-merge

git reset --hard HEAD
git checkout -b temp.$$

if git rebase $branch > /dev/null 2>&1; then
echo GIT-SMERGE: Rebase with $branch succeeded, using tree to create merge commit

if ! git checkout $current; then
echo GIT-SMERGE: Some strange problem occurred!
git branch -D temp.$$
exit 1
fi

git merge $branch > /dev/null 2>&1 # this is sure to fail
git clean -fd
git archive --format=tar temp.$$ | tar xf -
git branch -D temp.$$
git add .
git add -A
git ls-files --deleted -z | xargs -0 git rm
git commit
else
echo GIT-SMERGE: Rebase with $branch failed, returning to failed merge

git rebase --abort
git checkout -f $current
git branch -D temp.$$
git merge $branch > /dev/null 2>&1 # this is sure to fail
fi
fi

0 comments on commit b1f276e

Please sign in to comment.