]> git.ipfire.org Git - thirdparty/git.git/commitdiff
transport-helper: recognize "expecting report" error from send-pack
authorJeff King <peff@peff.net>
Mon, 18 Oct 2021 19:45:56 +0000 (15:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Oct 2021 20:27:36 +0000 (13:27 -0700)
When a transport helper pushes via send-pack, it passes --helper-status
to get a machine-readable status back for each ref. The previous commit
taught the send-pack code to hand back "error expecting report" if the
server did not send us the proper ref-status. And that's enough to cause
us to recognize that an error occurred for the ref and print something
sensible in our final status table.

But we do interpret these messages on the remote-helper side to turn
them back into REF_STATUS_* enum values.  Recognizing this token to turn
it back into REF_STATUS_EXPECTING_REPORT has two advantages:

  1. We now print exactly the same message in the human-readable (and
     machine-readable --porcelain) output for this situation whether the
     transport went through a helper (e.g., http) or not (e.g., ssh).

  2. If any code in the helper really cares about distinguishing
     EXPECT_REPORT from more generic error conditions, it could now do
     so. I didn't find any, so this is mostly future-proofing.

So this is mostly cosmetic for now, but it seems like the
least-surprising thing for the transport-helper code to be doing.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5541-http-push-smart.sh
transport-helper.c

index 9c61dccc24b31412f55f9c22c3088249708a5bae..8ca50f8b18c1ce68b553efffd1daaa57b730de07 100755 (executable)
@@ -519,7 +519,7 @@ test_expect_success 'report error server does not provide ref status' '
                rev-parse --verify refs/tags/will-fail &&
        cat >expect <<-EOF &&
        To $HTTPD_URL/smart/no_report
-       !       HEAD:refs/tags/will-fail        [remote rejected] (expecting report)
+       !       HEAD:refs/tags/will-fail        [remote failure] (remote failed to report status)
        Done
        EOF
        test_cmp expect actual
index 4be035edb8b7c6d618b4dc78ea5de203a2831391..56e36a4cf4616bf987c38274f28f7ededb52a286 100644 (file)
@@ -845,6 +845,10 @@ static int push_update_ref_status(struct strbuf *buf,
                        forced = 1;
                        FREE_AND_NULL(msg);
                }
+               else if (!strcmp(msg, "expecting report")) {
+                       status = REF_STATUS_EXPECTING_REPORT;
+                       FREE_AND_NULL(msg);
+               }
        }
 
        if (state->hint)