]> git.lizzy.rs Git - plan9front.git/commitdiff
git/send: allow the remote to have refs that we don't
authorOri Bernstein <ori@eigenstate.org>
Sun, 6 Jun 2021 03:29:57 +0000 (23:29 -0400)
committerOri Bernstein <ori@eigenstate.org>
Sun, 6 Jun 2021 17:07:51 +0000 (13:07 -0400)
It's not fatal for someone else to push a branch
with objects that we don't have. We should deal
with it gracefully, and act as though it doesn't
exist.

sys/src/cmd/git/send.c

index 1e44caa81753c73ec4d35d9538fb7b924ee61670..877c369e5adebebf334bc3bdf5f7e64c74e05332 100644 (file)
@@ -121,7 +121,7 @@ sendpack(Conn *c)
        int nours, ntheirs, nmap;
        char buf[Pktmax], *sp[3];
        Hash h, *theirs, *ours;
-       Object *a, *b, *p;
+       Object *a, *b, *p, *o;
        char **refs;
        Capset cs;
        Map *map, *m;
@@ -155,9 +155,12 @@ sendpack(Conn *c)
                theirs = earealloc(theirs, ntheirs+1, sizeof(Hash));
                if(hparse(&theirs[ntheirs], sp[0]) == -1)
                        sysfatal("invalid hash %s", sp[0]);
-               if((idx = findkey(map, nmap, sp[1])) != -1)
-                       map[idx].theirs = theirs[ntheirs];
-               ntheirs++;
+               if((o = readobject(theirs[ntheirs])) != nil){
+                       if((idx = findkey(map, nmap, sp[1])) != -1)
+                               map[idx].theirs = theirs[ntheirs];
+                       ntheirs++;
+                       unref(o);
+               }
        }
 
        if(writephase(c) == -1)