Initial implementation of merge conflict resolution support.
diff --git a/git-flow-feature b/git-flow-feature
index b9f18b7..18467a6 100644
--- a/git-flow-feature
+++ b/git-flow-feature
@@ -105,6 +105,31 @@
gitflow_require_clean_working_tree
gitflow_require_branch $BRANCH
+ # detect if we're restoring from a merge conflict
+ if [ -f "$GIT_DIR/.gitflow/MERGE_BASE" ]; then
+ #
+ # TODO: detect that we're working on the correct branch here!
+ # The user need not necessarily have given the same $NAME twice here
+ # (although he/she should).
+ #
+ FINISH_BASE="$(cat "$GIT_DIR/.gitflow/MERGE_BASE")"
+ if gitflow_is_branch_merged_into $BRANCH $FINISH_BASE; then
+ rm -f "$GIT_DIR/.gitflow/MERGE_BASE"
+ helper_finish_cleanup
+ exit 0
+ else
+ echo
+ echo "Merge conflicts not resolved yet, use:"
+ echo " git mergetool"
+ echo " git commit"
+ echo
+ echo "You can then complete the finish by running it again:"
+ echo " git flow feature finish $NAME"
+ echo
+ exit 1
+ fi
+ fi
+
# update local repo with remote changes first, if asked
if [ $FLAG_FETCH -eq 1 ]; then
git fetch -q $ORIGIN $BRANCH
@@ -125,8 +150,28 @@
git merge --no-ff $BRANCH
fi
+ if [ $? -ne 0 ]; then
+ # oops.. we have a merge conflict!
+ # write the given $BASE to a temporary file (we need it later)
+ mkdir -p "$GIT_DIR/.gitflow"
+ echo "$BASE" > "$GIT_DIR/.gitflow/MERGE_BASE"
+ echo
+ echo "There were merge conflicts. To resolve the merge conflict manually, use:"
+ echo " git mergetool"
+ echo " git commit"
+ echo
+ echo "You can then complete the finish by running it again:"
+ echo " git flow feature finish $NAME"
+ echo
+ exit 1
+ fi
+
+ # when no merge conflict is detected, just clean up the feature branch
+ helper_finish_cleanup
+}
+
+helper_finish_cleanup() {
# delete branch
- # TODO: How do we handle merge conflicts here??
git push $ORIGIN :refs/heads/$BRANCH
git branch -d $BRANCH