git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] Return non-zero status from pull if merge fails.
Date: Tue, 7 Nov 2006 13:10:53 -0500	[thread overview]
Message-ID: <20061107181053.GA26856@spearce.org> (raw)

If the merge operation fails during git-pull it usually exits with a
non-zero exit status to let the caller know it failed.  But git-pull
tossed that status away and always returned 0 (success), leading to
confusing output in any higher level interface which supplied both
the console output (showing the merge failure) and the exit status
(showing success).

So now git-pull just exec's git-merge, allowing its exit status to
be reported directly to the caller.

There were also a number of cases within git-merge which terminated
with a success (0) exit status despite having been caused by failure
to merge.  This is equally misleading and should return 1 instead.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 git-merge.sh |   10 +++++-----
 git-pull.sh  |    2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/git-merge.sh b/git-merge.sh
index cb09438..7725908 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -203,7 +203,7 @@ f,*)
 	git-update-index --refresh 2>/dev/null
 	new_head=$(git-rev-parse --verify "$1^0") &&
 	git-read-tree -u -v -m $head "$new_head" &&
-	finish "$new_head" "Fast forward"
+	finish "$new_head" "Fast forward" || exit 1
 	dropsave
 	exit 0
 	;;
@@ -214,7 +214,7 @@ f,*)
 ?,1,*,)
 	# We are not doing octopus, not fast forward, and have only
 	# one common.  See if it is really trivial.
-	git var GIT_COMMITTER_IDENT >/dev/null || exit
+	git var GIT_COMMITTER_IDENT >/dev/null || exit 1
 
 	echo "Trying really trivial in-index merge..."
 	git-update-index --refresh 2>/dev/null
@@ -225,7 +225,7 @@ f,*)
 	    result_commit=$(
 	        echo "$merge_msg" |
 	        git-commit-tree $result_tree -p HEAD -p "$1"
-	    ) || exit
+	    ) || exit 1
 	    finish "$result_commit" "In-index merge"
 	    dropsave
 	    exit 0
@@ -253,7 +253,7 @@ f,*)
 esac
 
 # We are going to make a new commit.
-git var GIT_COMMITTER_IDENT >/dev/null || exit
+git var GIT_COMMITTER_IDENT >/dev/null || exit 1
 
 # At this point, we need a real merge.  No matter what strategy
 # we use, it would operate on the index, possibly affecting the
@@ -327,7 +327,7 @@ done
 if test '' != "$result_tree"
 then
     parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
-    result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit
+    result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit 1
     finish "$result_commit" "Merge made by $wt_strategy."
     dropsave
     exit 0
diff --git a/git-pull.sh b/git-pull.sh
index ed04e7d..d10fcdd 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -102,6 +102,6 @@ case "$strategy_args" in
 esac
 
 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
-git-merge "--reflog-action=pull $*" \
+exec git-merge "--reflog-action=pull $*" \
 	$no_summary $no_commit $squash $strategy_args \
 	"$merge_name" HEAD $merge_head
-- 

             reply	other threads:[~2006-11-07 18:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-07 18:10 Shawn O. Pearce [this message]
2006-11-08  0:05 ` [PATCH] Return non-zero status from pull if merge fails Junio C Hamano
2006-11-08  5:10   ` Shawn Pearce
2006-11-08  5:36     ` Junio C Hamano
2006-11-08  5:52       ` Shawn Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061107181053.GA26856@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).