Skip to content

Commit

Permalink
Initial implementation of merge conflict resolution support.
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Jan 29, 2010
1 parent 58995b5 commit 49c7d02
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion git-flow-feature
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,31 @@ cmd_finish() {
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
Expand All @@ -125,8 +150,28 @@ cmd_finish() {
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

Expand Down

0 comments on commit 49c7d02

Please sign in to comment.