From: ori@eigenstate.org
To: 9front@9front.org
Subject: [9front] git/fetch: be more robust
Date: Sun, 25 Jul 2021 20:23:28 -0400 [thread overview]
Message-ID: <07AAA303A77F5CCCA03612746744A0DC@eigenstate.org> (raw)
currently, git/fetch prints the refs
to update before it fully fetches the
pack files; this can lead to updates
to the refs before we're 100% certain
that the objects are present.
This change prints the updates after
the packfile has been successfully
indexed.
I've been running with this for a bit,
and it passes the tests in
gits://shithub.us/ori/regress
so I'm reasonably confident it works,
but considering that bugs in the past
have caused major pain -- test reports
wanted:
--- //.git/fs/object/28f76455d39d990b47c6e46e18158f0a9ba09d25/tree/sys/src/cmd/git/fetch.c
+++ sys/src/cmd/git/fetch.c
@@ -181,7 +181,7 @@
fetchpack(Conn *c)
{
char buf[Pktmax], *sp[3];
- char *packtmp, *idxtmp;
+ char *packtmp, *idxtmp, **ref;
Hash h, *have, *want;
int nref, refsz, first;
int i, n, req, pfd;
@@ -193,6 +193,7 @@
first = 1;
have = eamalloc(refsz, sizeof(have[0]));
want = eamalloc(refsz, sizeof(want[0]));
+ ref = eamalloc(refsz, sizeof(ref[0]));
while(1){
n = readpkt(c, buf, sizeof(buf));
if(n == -1)
@@ -213,14 +214,15 @@
continue;
if(refsz == nref + 1){
refsz *= 2;
- have = erealloc(have, refsz * sizeof(have[0]));
- want = erealloc(want, refsz * sizeof(want[0]));
+ have = earealloc(have, refsz, sizeof(have[0]));
+ want = earealloc(want, refsz, sizeof(want[0]));
+ ref = earealloc(ref, refsz, sizeof(ref[0]));
}
+ ref[nref] = estrdup(sp[1]);
if(hparse(&want[nref], sp[0]) == -1)
sysfatal("invalid hash %s", sp[0]);
- if (resolveremote(&have[nref], sp[1]) == -1)
+ if (resolveremote(&have[nref], ref[nref]) == -1)
memset(&have[nref], 0, sizeof(have[nref]));
- print("remote %s %H local %H\n", sp[1], want[nref], have[nref]);
nref++;
}
if(listonly){
@@ -295,6 +297,14 @@
fail(packtmp, idxtmp, "could not index fetched pack: %r");
if(rename(packtmp, idxtmp, h) == -1)
fail(packtmp, idxtmp, "could not rename indexed pack: %r");
+
+ for(i = 0; i < nref; i++){
+ print("remote %s %H local %H\n", ref[i], want[i], have[i]);
+ free(ref[i]);
+ }
+ free(ref);
+ free(want);
+ free(have);
return 0;
}
next reply other threads:[~2021-07-26 0:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 0:23 ori [this message]
2021-07-26 0:36 ` [9front] " Anthony Martin
2021-07-26 1:39 ` ori
2021-07-26 0:45 ` [9front] " cinap_lenrek
2021-07-26 1:42 ` ori
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=07AAA303A77F5CCCA03612746744A0DC@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).