diff --git a/git-remote-testgit b/git-remote-testgit index 5fd09f965a..ff36d1d39d 100755 --- a/git-remote-testgit +++ b/git-remote-testgit @@ -97,7 +97,12 @@ do while read ref a b do test $a == $b && continue - echo "ok $ref" + if test -z "$GIT_REMOTE_TESTGIT_PUSH_ERROR" + then + echo "ok $ref" + else + echo "error $ref $GIT_REMOTE_TESTGIT_PUSH_ERROR" + fi done echo diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index 0b13d10698..443e228ec5 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -167,6 +167,20 @@ test_expect_success 'push update refs' ' ) ' +test_expect_success 'push update refs failure' ' + (cd local && + git checkout update && + echo "update fail" >>file && + git commit -a -m "update fail" && + git rev-parse --verify testgit/origin/heads/update >expect && + GIT_REMOTE_TESTGIT_PUSH_ERROR="non-fast forward" && + export GIT_REMOTE_TESTGIT_PUSH_ERROR && + test_expect_code 1 git push origin update && + git rev-parse --verify testgit/origin/heads/update >actual && + test_cmp expect actual + ) +' + test_expect_success 'proper failure checks for fetching' ' (GIT_REMOTE_TESTGIT_FAILURE=1 && export GIT_REMOTE_TESTGIT_FAILURE && diff --git a/transport-helper.c b/transport-helper.c index 92174095ed..6cd0be90e0 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -701,7 +701,7 @@ static int push_update_ref_status(struct strbuf *buf, (*ref)->status = status; (*ref)->remote_status = msg; - return 0; + return !(status == REF_STATUS_OK); } static void push_update_refs_status(struct helper_data *data,