shithub: git9

Download patch

ref: 4a91150765507009e4f07e8dfc8db90232ea5672
parent: f33ecd57228be94d3b6d777195ad93153e5c023a
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Feb 5 00:17:33 EST 2021

git/query: fix ref range refcount

Because we now unref objects, they can fall out
of cache. Reload them if needed.

--- a/ref.c
+++ b/ref.c
@@ -50,16 +50,20 @@
 objdatecmp(void *pa, void *pb)
 {
 	Object *a, *b;
+	int r;
 
-	a = *(Object**)pa;
-	b = *(Object**)pb;
+	a = readobject((*(Object**)pa)->hash);
+	b = readobject((*(Object**)pb)->hash);
 	assert(a->type == GCommit && b->type == GCommit);
 	if(a->commit->mtime == b->commit->mtime)
-		return 0;
+		r = 0;
 	else if(a->commit->mtime < b->commit->mtime)
-		return -1;
+		r = -1;
 	else
-		return 1;
+		r = 1;
+	unref(a);
+	unref(b);
+	return r;
 }
 
 void