From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=RDNS_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 7010 invoked from network); 12 Apr 2022 02:57:38 -0000 Received: from unknown (HELO 9front.inri.net) (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 12 Apr 2022 02:57:38 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 9front; Mon Apr 11 22:55:10 -0400 2022 Received: from abbatoir.myfiosgateway.com (pool-74-108-56-225.nycmny.fios.verizon.net [74.108.56.225]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 6065b818 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Mon, 11 Apr 2022 19:55:01 -0700 (PDT) Message-ID: <404C9B5CFE08FE9146154E6D8964C191@eigenstate.org> To: 9front@9front.org Date: Mon, 11 Apr 2022 22:55:00 -0400 From: ori@eigenstate.org In-Reply-To: <6E68ADE1468D00715CFB8A660CA41558@eigenstate.org> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: open-source open-source method cloud information frontend Subject: Re: [9front] git/pull: fetch all branches (please test) Reply-To: 9front@9front.org Precedence: bulk Quoth ori@eigenstate.org: > Quoth ori@eigenstate.org: > > Here's the work in progress > > And here's an updated work in progress that works around > the bug more directly: And one more iteration that doesn't shit up the packfile, and will handle things right even if you name a branch PACK. diff 1d9d4ffef89e883949261ec9c56c57e0344726d7 uncommitted --- a/sys/src/cmd/git/fetch.c +++ b/sys/src/cmd/git/fetch.c @@ -180,12 +180,13 @@ int fetchpack(Conn *c) { - char buf[Pktmax], *sp[3]; + char buf[Pktmax], *sp[3], *ep; char *packtmp, *idxtmp, **ref; Hash h, *have, *want; int nref, refsz, first; - int i, n, req, pfd; + int i, n, l, 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); @@ -260,7 +267,7 @@ if(writepkt(c, buf, n) == -1) sysfatal("write: %r"); if(!req) - return 0; + goto showrefs; if(readphase(c) == -1) sysfatal("read: %r"); if((n = readpkt(c, buf, sizeof(buf))) == -1) @@ -277,7 +284,28 @@ sysfatal("could not create %s: %r", packtmp); fprint(2, "fetching...\n"); - packsz = 0; + /* + * Work around torvalds git bug: we get duplicate have lines + * somtimes, even though the protocol is supposed to start the + * pack file immediately. + * + * Skip ahead until we read 'PACK' off the wire + */ + while(1){ + if(readn(c->rfd, buf, 4) != 4) + sysfatal("fetch packfile: short read"); + buf[4] = 0; + if(strncmp(buf, "PACK", 4) == 0) + break; + l = strtol(buf, &ep, 16); + if(l == 0 || ep != buf + 4) + sysfatal("fetch packfile: junk pktline"); + if(readn(c->rfd, buf, l) != l) + sysfatal("fetch packfile: short read"); + } + if(write(pfd, "PACK", 4) != 4) + sysfatal("write pack header: %r"); + packsz = 4; while(1){ n = read(c->rfd, buf, sizeof buf); if(n == 0) --- a/sys/src/cmd/git/pull +++ b/sys/src/cmd/git/pull @@ -7,13 +7,10 @@ upstream=$2 url=$3 dir=$4 - bflag=() dflag=() - if(! ~ $#branch 0) - bflag=(-b $branch) if(! ~ $#debug 0) dflag='-d' - {git/fetch $dflag $bflag -u $upstream $url >[2=3] || die $status} | awk ' + {git/fetch $dflag -u $upstream $url >[2=3] || die $status} | awk ' /^remote/{ if($2=="HEAD") next