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

Re: [PATCH v2 3/3] send-pack: assign remote errors to each ref

From
Jeff King <peff@peff.net>
Date
Nov 15, 2007, 04:47 UTC
Message-ID
<20071115044715.GB9794@sigill.intra.peff.net>
In-Reply-To
<7vbq9xpprg.fsf@gitster.siamese.dyndns.org>
On Tue, Nov 13, 2007 at 05:41:39PM -0800, Junio C Hamano wrote:
> Is it really "arbitrary msg", or just a fixed set of strings?

It is for a fixed version of the remote receive-pack, but I don't want to start relying on that.

> Also I think we can rely on the order report-status extension
> reports the per-ref result.  It gives back the information the
> same order send-pack side supplies the head information, no?

I considered that, but I didn't want to rely on it without your say-so. We could also just use it as a hint to boost performance. I.e., track the last match, and start our linear search there, but if we fail, drop back to searching the whole list. Something like (on top of my other patch):

diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 7d466d9..8e9580a 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -146,7 +146,8 @@ static void get_local_heads(void)
 	for_each_ref(one_local_ref, NULL);
 }
 
-static void set_ref_error(struct ref *refs, const char *line) {
+static struct ref *set_ref_error(struct ref *refs, const char *line)
+{
 	struct ref *ref;
 
 	for (ref = refs; ref; ref = ref->next) {
@@ -159,8 +160,9 @@ static void set_ref_error(struct ref *refs, const char *line) {
 		ref->status = REF_STATUS_REMOTE_REJECT;
 		ref->error = xstrdup(msg);
 		ref->error[strlen(ref->error)-1] = '\0';
-		return;
+		return ref;
 	}
+	return NULL;
 }
 
 /* a return value of -1 indicates that an error occurred,
@@ -168,6 +170,7 @@ static void set_ref_error(struct ref *refs, const char *line) {
  * value of -2 means we couldn't even get that far. */
 static int receive_status(int in, struct ref *refs)
 {
+	struct ref *hint;
 	char line[1000];
 	int ret = 0;
 	int len = packet_read_line(in, line, sizeof(line));
@@ -179,6 +182,7 @@ static int receive_status(int in, struct ref *refs)
 		fputs(line, stderr);
 		ret = -1;
 	}
+	hint = NULL;
 	while (1) {
 		len = packet_read_line(in, line, sizeof(line));
 		if (!len)
@@ -191,7 +195,10 @@ static int receive_status(int in, struct ref *refs)
 		}
 		if (!memcmp(line, "ok", 2))
 			continue;
-		set_ref_error(refs, line + 3);
+		if (hint)
+			hint = set_ref_error(hint, line + 3);
+		if (!hint)
+			hint = set_ref_error(refs, line + 3);
 		ret = -1;
 	}
 	return ret;
Previous: Junio C Hamano
Message 20 of 20 in “tracking per-ref errors on push”
  1. 0/3 tracking per-ref errors on pushJeff King, Nov 13, 2007
  2. 1/3 send-pack: track errors for each refJeff King, Nov 13, 2007
  3. Jeff KingNov 13, 2007
  4. Alex RiesenNov 13, 2007
  5. Jeff KingNov 13, 2007
  6. Alex RiesenNov 13, 2007
  7. 2/3 send-pack: check ref->status before updating tracking refsJeff King, Nov 13, 2007
  8. 3/3 send-pack: assign remote errors to each refJeff King, Nov 13, 2007
  9. Jeff KingNov 13, 2007
  10. Jeff KingNov 13, 2007
  11. 1/3 send-pack: track errors for each refJeff King, Nov 13, 2007
  12. 2/3 send-pack: check ref->status before updating tracking refsJeff King, Nov 13, 2007
  13. 3/3 send-pack: assign remote errors to each refJeff King, Nov 13, 2007
  14. Junio C HamanoNov 14, 2007
  15. Junio C HamanoNov 14, 2007
  16. Johannes SchindelinNov 14, 2007
  17. Junio C HamanoNov 14, 2007
  18. Jeff KingNov 15, 2007
  19. Junio C HamanoNov 16, 2007
  20. Jeff KingNov 15, 2007

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.