ref: 37a8fc6168b3bf82df198fb20be5a8a53996187c
parent: abc6e8ee6b71a79e7bfe5926132cd2302860ffe6
author: Ori Bernstein <[email protected]>
date: Sat Dec 23 17:24:07 EST 2023
ref: check if object is a commit when needed
--- a/sys/src/cmd/git/ref.c
+++ b/sys/src/cmd/git/ref.c
@@ -188,6 +188,10 @@
break;
}
o = readobject(e.o->hash);
+ if(o->type != GCommit){
+ werrstr("not a commit: %H", o->hash);
+ goto error;
+ }
for(i = 0; i < o->commit->nparent; i++){
if((c = readobject(e.o->commit->parent[i])) == nil)
goto error;
@@ -305,6 +309,10 @@
Object *o, *p;
o = pop(ev);
+ if(o->type != GCommit){
+ werrstr("not a commit: %H", o->hash);
+ return -1;
+ }
/* Special case: first commit has no parent. */
if(o->commit->nparent == 0)
p = emptydir();