shithub: git9

Download patch

ref: 8bbf796fb72edb83f540663ecfe83eb4cfab599f
parent: 9ec38f3162c5c7f1a7fe136bab160e76df13a7ba
author: Ori Bernstein <[email protected]>
date: Thu Oct 17 18:15:07 EDT 2019

Fix ancestor check in send.c

--- a/send.c
+++ b/send.c
@@ -287,7 +287,7 @@
 int
 sendpack(int fd)
 {
-	int i, n, r, nupd, nsp, sendpack;
+	int i, n, r, nupd, nsp, send;
 	char buf[Pktmax], *sp[3];
 	Update *upd, *u;
 	Object *a, *b;
@@ -313,7 +313,7 @@
 	}
 
 	r = 0;
-	sendpack = 0;
+	send = 0;
 	for(i = 0; i < nupd; i++){
 		u = &upd[i];
 		a = readobject(u->theirs);
@@ -321,7 +321,7 @@
 		if(!force && !hasheq(&u->theirs, &Zhash) && (a == nil || ancestor(a, b) != a)){
 			fprint(2, "remote has diverged\n");
 			werrstr("force needed");
-			sendpack=0;
+			send=0;
 			r = -1;
 			break;
 		}
@@ -356,11 +356,13 @@
 		 * If we're rolling back with a force push, the other side already
 		 * has our changes. There's no need to send a pack if that's the case.
 		 */
-		if(!ancestor(b, a))
-			sendpack = 1;
+		if(ancestor(b, a) != b)
+			send = 1;
 	}
 	flushpkt(fd);
-	if(sendpack){
+	if(!send)
+		print("nothing to send\n");
+	if(send){
 		if(writepack(fd, upd, nupd) == -1)
 			return -1;