shithub: git9

Download patch

ref: 470632864bf1cb0f48cf577a0ad8186cd673d735
parent: d2149bc37264e9a32700f174eeb64023a567420c
author: Ori Bernstein <[email protected]>
date: Sat Feb 13 13:28:47 EST 2021

git/query: make range stop at first commit (thanks phil9)

Querying git/query HEAD `{seq -f ~ 100} .. HEAD would
error because one of the commits would have no parent.
This is not the desired behavior: we should instead
truncate the range at the first commit.

--- a/ref.c
+++ b/ref.c
@@ -407,6 +407,10 @@
 
 	b = pop(ev);
 	a = pop(ev);
+	if(hasheq(&b->hash, &Zhash))
+		b = &zcommit;
+	if(hasheq(&a->hash, &Zhash))
+		a = &zcommit;
 	if(a->type != GCommit || b->type != GCommit){
 		werrstr("non-commit object in range");
 		return -1;