9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: 9front@9front.org
Subject: [9front] git: only send object ids once
Date: Sat, 25 Dec 2021 20:11:35 -0500	[thread overview]
Message-ID: <AB51FD369B9C2B2D808F71DA93C8B21C@eigenstate.org> (raw)

When fetching, we could send some object ids twice,
if the same branch was pointing at the same object.

This appears to tickle some issue in upstream git,
making it fail to respect the fetch protocol, and
sending multiple ack lines where it should send one.

this change adds a set of objects we said we have,
and we only send if we haven't already sent it.

later, we will implement multi_ack.

diff facb0e757ac63f763bd942a2714f979538b99eb0 uncommitted
--- a/sys/src/cmd/git/fetch.c
+++ b/sys/src/cmd/git/fetch.c
@@ -186,6 +186,7 @@
 	int nref, refsz, first;
 	int i, n, req, pfd;
 	vlong packsz;
+	Objset hadobj;
 	Object *o;
 
 	nref = 0;
@@ -246,13 +247,19 @@
 		req = 1;
 	}
 	flushpkt(c);
+	osinit(&hadobj);
 	for(i = 0; i < nref; i++){
-		if(hasheq(&have[i], &Zhash))
+		if(hasheq(&have[i], &Zhash) || oshas(&hadobj, have[i]))
 			continue;
+		if((o = readobject(have[i])) == nil)
+			sysfatal("missing object we should have: %H", have[i]);
+		osadd(&hadobj, o);
+		unref(o);	
 		n = snprint(buf, sizeof(buf), "have %H\n", have[i]);
 		if(writepkt(c, buf, n + 1) == -1)
 			sysfatal("could not send have for %H", have[i]);
 	}
+	osclear(&hadobj);
 	if(!req)
 		flushpkt(c);
 


                 reply	other threads:[~2021-12-26  1:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AB51FD369B9C2B2D808F71DA93C8B21C@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).