diff options
author | Ori Bernstein <ori@eigenstate.org> | 2023-04-17 21:11:47 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2023-04-17 21:11:47 +0000 |
commit | 4d901d1e4165085cda5b574b44e1cc51be50abf8 (patch) | |
tree | d8a0e4163181158207d0546c69b9bc42a397570d /sys/src/cmd/git | |
parent | dd676b5a4fa19fcbe608598e73e3ee6b5bd5ad84 (diff) |
git/send: correctly delete branches with no local mirror
Diffstat (limited to 'sys/src/cmd/git')
-rw-r--r-- | sys/src/cmd/git/proto.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/git/ref.c | 4 | ||||
-rw-r--r-- | sys/src/cmd/git/send.c | 9 |
3 files changed, 15 insertions, 4 deletions
diff --git a/sys/src/cmd/git/proto.c b/sys/src/cmd/git/proto.c index 9af09ec19..3f5292aa7 100644 --- a/sys/src/cmd/git/proto.c +++ b/sys/src/cmd/git/proto.c @@ -58,8 +58,10 @@ readpkt(Conn *c, char *buf, int nbuf) char *e; int n; - if(readn(c->rfd, len, 4) != 4) - sysfatal("pktline: short read from transport"); + if(readn(c->rfd, len, 4) != 4){ + werrstr("pktline: short read from transport"); + return -1; + } len[4] = 0; n = strtol(len, &e, 16); if(n == 0){ diff --git a/sys/src/cmd/git/ref.c b/sys/src/cmd/git/ref.c index 5dadbd27a..fd732c944 100644 --- a/sys/src/cmd/git/ref.c +++ b/sys/src/cmd/git/ref.c @@ -125,6 +125,8 @@ paint(Hash *head, int nhead, Hash *tail, int ntail, Object ***res, int *nres, in nskip = 0; for(i = 0; i < nhead; i++){ + if(hasheq(&head[i], &Zhash)) + continue; if((o = readobject(head[i])) == nil){ fprint(2, "warning: %H does not point at commit\n", head[i]); werrstr("read head %H: %r", head[i]); @@ -140,6 +142,8 @@ paint(Hash *head, int nhead, Hash *tail, int ntail, Object ***res, int *nres, in unref(o); } for(i = 0; i < ntail; i++){ + if(hasheq(&head[i], &Zhash)) + continue; if((o = readobject(tail[i])) == nil){ werrstr("read tail %H: %r", tail[i]); return -1; diff --git a/sys/src/cmd/git/send.c b/sys/src/cmd/git/send.c index 1188a71fa..e83d6866f 100644 --- a/sys/src/cmd/git/send.c +++ b/sys/src/cmd/git/send.c @@ -75,9 +75,11 @@ readours(Hash **tailp, char ***refp) sysfatal("smprint: %r"); if((idx = findref(ref, nu, r)) == -1) idx = nu++; + else + free(ref[idx]); assert(idx < nremoved + nbranch); memcpy(&tail[idx], &Zhash, sizeof(Hash)); - free(r); + ref[idx] = r; } dprint(1, "nu: %d\n", nu); for(i = 0; i < nu; i++) @@ -184,7 +186,10 @@ sendpack(Conn *c) p = nil; if(a != nil && b != nil) p = ancestor(a, b); - if(!force && !hasheq(&m->theirs, &Zhash) && (a == nil || p != a)){ + if(!force + && !hasheq(&m->theirs, &Zhash) + && !hasheq(&m->ours, &Zhash) + && (a == nil || p != a)){ fprint(2, "remote has diverged\n"); werrstr("remote diverged"); flushpkt(c); |