M fetch.c => fetch.c +6 -1
@@ 228,8 228,13 @@ fetchpack(Conn *c, int pfd, char *packtmp)
req = 1;
}
flushpkt(c);
+ if(resolveref(&h, "HEAD") != -1){
+ n = snprint(buf, sizeof(buf), "have %H\n", h);
+ if(writepkt(c, buf, n + 1) == -1)
+ sysfatal("could not send have for %H", have[i]);
+ }
for(i = 0; i < nref; i++){
- if(hasheq(&have[i], &Zhash))
+ if(hasheq(&have[i], &Zhash) || hasheq(&have[i], &h))
continue;
n = snprint(buf, sizeof(buf), "have %H\n", have[i]);
if(writepkt(c, buf, n + 1) == -1)
M pack.c => pack.c +2 -1
@@ 1000,7 1000,8 @@ readidxobject(Biobuf *idx, Hash h, int flag)
retried = 0;
retry:
for(i = 0; i < npackf; i++){
- if((o = searchindex(packf[i].idx, packf[i].nidx, h)) != -1){
+ o = searchindex(packf[i].idx, packf[i].nidx, h);
+ if(o != -1){
if((f = openpack(&packf[i])) == nil)
goto error;
if((r = Bseek(f, o, 0)) != -1)
M util.c => util.c +4 -2
@@ 67,7 67,8 @@ eamalloc(ulong n, ulong sz)
uvlong na;
void *v;
- if((na = (uvlong)n*(uvlong)sz) >= (1ULL<<30))
+ na = (uvlong)n*(uvlong)sz;
+ if(na >= (1ULL<<30))
sysfatal("alloc: overflow");
v = mallocz(na, 1);
if(v == nil)
@@ 94,7 95,8 @@ earealloc(void *p, ulong n, ulong sz)
uvlong na;
void *v;
- if((na = (uvlong)n*(uvlong)sz) >= (1ULL<<30))
+ na = (uvlong)n*(uvlong)sz;
+ if(na >= (1ULL<<30))
sysfatal("alloc: overflow");
v = realloc(p, na);
if(v == nil)