git/push, git/send: get better about erroring out early
git/push died within a subshell, which prevented the whole program from exiting, and lead to an incorrect ref update line that confused people. git/send would eventually error out, but would push all the data before that happened; this was annoying.
This commit is contained in:
parent
c9bf96e3e0
commit
8ab397c23c
2 changed files with 27 additions and 14 deletions
|
@ -1202,16 +1202,19 @@ indexpack(char *pack, char *idx, Hash ph)
|
||||||
while(c < nobj && (obj[c]->hash.h[0] & 0xff) <= i)
|
while(c < nobj && (obj[c]->hash.h[0] & 0xff) <= i)
|
||||||
c++;
|
c++;
|
||||||
PUTBE32(buf, c);
|
PUTBE32(buf, c);
|
||||||
hwrite(f, buf, 4, &st);
|
if(hwrite(f, buf, 4, &st) == -1)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
for(i = 0; i < nobj; i++){
|
for(i = 0; i < nobj; i++){
|
||||||
o = obj[i];
|
o = obj[i];
|
||||||
hwrite(f, o->hash.h, sizeof(o->hash.h), &st);
|
if(hwrite(f, o->hash.h, sizeof(o->hash.h), &st) == -1)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < nobj; i++){
|
for(i = 0; i < nobj; i++){
|
||||||
PUTBE32(buf, obj[i]->crc);
|
PUTBE32(buf, obj[i]->crc);
|
||||||
hwrite(f, buf, 4, &st);
|
if(hwrite(f, buf, 4, &st) == -1)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbig = 0;
|
nbig = 0;
|
||||||
|
@ -1222,15 +1225,18 @@ indexpack(char *pack, char *idx, Hash ph)
|
||||||
PUTBE32(buf, (1ull << 31) | nbig);
|
PUTBE32(buf, (1ull << 31) | nbig);
|
||||||
nbig++;
|
nbig++;
|
||||||
}
|
}
|
||||||
hwrite(f, buf, 4, &st);
|
if(hwrite(f, buf, 4, &st) == -1)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
for(i = 0; i < nobj; i++){
|
for(i = 0; i < nobj; i++){
|
||||||
if(obj[i]->off >= (1ull<<31)){
|
if(obj[i]->off >= (1ull<<31)){
|
||||||
PUTBE64(buf, obj[i]->off);
|
PUTBE64(buf, obj[i]->off);
|
||||||
hwrite(f, buf, 8, &st);
|
if(hwrite(f, buf, 8, &st) == -1)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hwrite(f, ph.h, sizeof(ph.h), &st);
|
if(hwrite(f, ph.h, sizeof(ph.h), &st) == -1)
|
||||||
|
goto error;
|
||||||
sha1(nil, 0, h.h, st);
|
sha1(nil, 0, h.h, st);
|
||||||
Bwrite(f, h.h, sizeof(h.h));
|
Bwrite(f, h.h, sizeof(h.h));
|
||||||
|
|
||||||
|
@ -1630,7 +1636,7 @@ genpack(int fd, Meta **meta, int nmeta, Hash *h, int odelta)
|
||||||
DigestState *st;
|
DigestState *st;
|
||||||
Biobuf *bfd;
|
Biobuf *bfd;
|
||||||
Meta *m;
|
Meta *m;
|
||||||
Object *o, *b;
|
Object *o, *po, *b;
|
||||||
char *p, buf[32];
|
char *p, buf[32];
|
||||||
|
|
||||||
st = nil;
|
st = nil;
|
||||||
|
@ -1655,27 +1661,34 @@ genpack(int fd, Meta **meta, int nmeta, Hash *h, int odelta)
|
||||||
for(i = 0; i < nmeta; i++){
|
for(i = 0; i < nmeta; i++){
|
||||||
pct = showprogress((i*100)/nmeta, pct);
|
pct = showprogress((i*100)/nmeta, pct);
|
||||||
m = meta[i];
|
m = meta[i];
|
||||||
m->off = Boffset(bfd);
|
if((m->off = Boffset(bfd)) == -1)
|
||||||
|
goto error;
|
||||||
if((o = readobject(m->obj->hash)) == nil)
|
if((o = readobject(m->obj->hash)) == nil)
|
||||||
return -1;
|
return -1;
|
||||||
if(m->delta == nil){
|
if(m->delta == nil){
|
||||||
nh = packhdr(buf, o->type, o->size);
|
nh = packhdr(buf, o->type, o->size);
|
||||||
hwrite(bfd, buf, nh, &st);
|
if(hwrite(bfd, buf, nh, &st) == -1)
|
||||||
|
goto error;
|
||||||
if(hcompress(bfd, o->data, o->size, &st) == -1)
|
if(hcompress(bfd, o->data, o->size, &st) == -1)
|
||||||
goto error;
|
goto error;
|
||||||
}else{
|
}else{
|
||||||
b = readobject(m->prev->obj->hash);
|
if((b = readobject(m->prev->obj->hash)) == nil)
|
||||||
|
goto error;
|
||||||
nd = encodedelta(m, o, b, &p);
|
nd = encodedelta(m, o, b, &p);
|
||||||
unref(b);
|
unref(b);
|
||||||
if(odelta && m->prev->off != 0){
|
if(odelta && m->prev->off != 0){
|
||||||
nh = 0;
|
nh = 0;
|
||||||
nh += packhdr(buf, GOdelta, nd);
|
nh += packhdr(buf, GOdelta, nd);
|
||||||
nh += packoff(buf+nh, m->off - m->prev->off);
|
nh += packoff(buf+nh, m->off - m->prev->off);
|
||||||
hwrite(bfd, buf, nh, &st);
|
if(hwrite(bfd, buf, nh, &st) == -1)
|
||||||
|
goto error;
|
||||||
}else{
|
}else{
|
||||||
nh = packhdr(buf, GRdelta, nd);
|
nh = packhdr(buf, GRdelta, nd);
|
||||||
hwrite(bfd, buf, nh, &st);
|
po = m->prev->obj;
|
||||||
hwrite(bfd, m->prev->obj->hash.h, sizeof(m->prev->obj->hash.h), &st);
|
if(hwrite(bfd, buf, nh, &st) == -1)
|
||||||
|
goto error;
|
||||||
|
if(hwrite(bfd, po->hash.h, sizeof(po->hash.h), &st) == -1)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
res = hcompress(bfd, p, nd, &st);
|
res = hcompress(bfd, p, nd, &st);
|
||||||
free(p);
|
free(p);
|
||||||
|
|
|
@ -31,7 +31,7 @@ branch=-b^$branch
|
||||||
if(! ~ $#remove 0)
|
if(! ~ $#remove 0)
|
||||||
remove=-r^$remove
|
remove=-r^$remove
|
||||||
for(remote in $remotes){
|
for(remote in $remotes){
|
||||||
updates=`$nl{git/send $debug $force $branch $remove $remote || die $status}
|
updates=`$nl{git/send $debug $force $branch $remove $remote} || die $status
|
||||||
for(ln in $updates){
|
for(ln in $updates){
|
||||||
u=`{echo $ln}
|
u=`{echo $ln}
|
||||||
refpath=`{echo $u(2) | subst '^refs/heads/' '.git/refs/remotes/'$upstream'/'}
|
refpath=`{echo $u(2) | subst '^refs/heads/' '.git/refs/remotes/'$upstream'/'}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue