transport-helper: fix remote helper namespace regression
authorFelipe Contreras <felipe.contreras@gmail.com>
Fri, 10 May 2013 12:08:30 +0000 (07:08 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 May 2013 20:28:31 +0000 (13:28 -0700)
Commit 664059f (transport-helper: update remote helper namespace)
updates the namespace when the push succeeds or not; we should do it
only when it succeeded.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-remote-testgit
t/t5801-remote-helpers.sh
transport-helper.c
index 5fd09f965a644a279ac79f5f1d0748650744e922..ff36d1d39d1c9bd1fce1843ba6a6eee7f023f131 100755 (executable)
@@ -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
index 0b13d106987422e10a039b1db926da7473811b9a..443e228ec5d34d293e1fdcf60ee4074c57e04549 100755 (executable)
@@ -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 &&
index 92174095eda4f2446f97bdb2854e533080c0c834..6cd0be90e0a4e6d377004d8dbf37ae9f254640f4 100644 (file)
@@ -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,