9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] git: only send object ids once
@ 2021-12-26  1:11 ori
  0 siblings, 0 replies; only message in thread
From: ori @ 2021-12-26  1:11 UTC (permalink / raw)
  To: 9front

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;
+	osinit(&hadobj);
 	for(i = 0; i < nref; i++){
-		if(hasheq(&have[i], &Zhash))
+		if(hasheq(&have[i], &Zhash) || oshas(&hadobj, have[i]))
+		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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-26  1:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-26  1:11 [9front] git: only send object ids once ori

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).