git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] transport-helper: recognize "expecting report" error from send-pack

From
Jeff King <peff@peff.net>
Date
Oct 18, 2021, 19:45 UTC
Message-ID
<YW3O9EYdHq4BhQqD@coredump.intra.peff.net>
In-Reply-To
<YW3MY6lAI5l+BOnP@coredump.intra.peff.net>

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>
---
Yes, the "else if" is not cuddled below. It matches the rest of the
existing if/else chain.
 t/t5541-http-push-smart.sh | 2 +-
 transport-helper.c         | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
index 9c61dccc24..8ca50f8b18 100755
--- a/t/t5541-http-push-smart.sh
+++ b/t/t5541-http-push-smart.sh
@@ -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
diff --git a/transport-helper.c b/transport-helper.c
index e8dbdd1153..a0297b0986 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -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)
-- 
2.33.1.1223.g80c1dbe6e5
Previous: Junio C HamanoNext: brian m. carlson
Message 4 of 5 in “handling REF_STATUS_EXPECTING_REPORT over http”
  1. 0/2 handling REF_STATUS_EXPECTING_REPORT over httpJeff King, Oct 18, 2021
  2. 1/2 send-pack: complain about "expecting report" with --helper-statusJeff King, Oct 18, 2021
  3. Junio C HamanoOct 18, 2021
  4. 2/2 transport-helper: recognize "expecting report" error from send-packJeff King, Oct 18, 2021
  5. brian m. carlsonOct 19, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.