Made the finishing of release/hotfix branches fail-safe. When a
release/hotfix branch fails finishing, the user may just try so again.
diff --git a/git-flow-hotfix b/git-flow-hotfix
index 9b9974e..2bceb5e 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -170,22 +170,41 @@
 	gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
 	gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
 
-	# merge into master
-	git checkout $MASTER_BRANCH || \
-	  die "Could not check out $MASTER_BRANCH."
-	git merge --no-ff $BRANCH	# TODO: This can fail!
+	# try to merge into master
+	# in case a previous attempt to finish this release branch has failed,
+	# but the merge into master was successful, we skip it now
+	if ! gitflow_is_branch_merged_into $BRANCH $MASTER_BRANCH; then
+		git checkout $MASTER_BRANCH || \
+		  die "Could not check out $MASTER_BRANCH."
+		git merge --no-ff $BRANCH || \
+		  die "There were merge conflicts."
+		  # TODO: What do we do now?
+	fi
 
-	typeset opts="-a"
-	flag sign && opts="$opts -s"
-	[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
-	[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
-	git tag $opts "$VERSION_PREFIX$VERSION" || \
-	  die "Tagging failed. Please run finish again to retry."
+	# try to tag the release
+	# in case a previous attempt to finish this release branch has failed,
+	# but the tag was set successful, we skip it now
+	typeset tagname=$VERSION_PREFIX$VERSION
+	if ! gitflow_tag_exists $tagname; then
+		typeset opts="-a"
+		flag sign && opts="$opts -s"
+		[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
+		[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
+		git tag $opts "$VERSION_PREFIX$VERSION" || \
+		  die "Tagging failed. Please run finish again to retry."
+	fi
 
-	# merge into develop
-	git checkout $DEVELOP_BRANCH || \
-	  die "Could not check out $DEVELOP_BRANCH."
-	git merge --no-ff $BRANCH	# TODO: This can fail!
+	# try to merge into develop
+	# in case a previous attempt to finish this release branch has failed,
+	# but the merge into develop was successful, we skip it now
+	if ! gitflow_is_branch_merged_into $BRANCH $DEVELOP_BRANCH; then
+		git checkout $DEVELOP_BRANCH || \
+		  die "Could not check out $DEVELOP_BRANCH."
+
+		git merge --no-ff $BRANCH || \
+		  die "There were merge conflicts."
+		  # TODO: What do we do now?
+	fi
 
 	# delete branch
 	git branch -d $BRANCH