shithub: git9

Download patch

ref: 36224fde10f6d42dbd12d1bb8e4010f91f18a1a7
parent: 52bd6a558338111c5f787ccc1d3b5f999c0e010f
author: Ori Bernstein <[email protected]>
date: Sat Jun 5 23:25:31 EDT 2021

git/send: allow the remote to have refs that we don't

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.

--- a/send.c
+++ b/send.c
@@ -121,7 +121,7 @@
 	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 @@
 		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)