git: use commit date as traversal hint instead of author date

Although git9 always uses the same commit date and author date, other
implementation do make a distinction.  Since commit date is more
representative of the commit graph order, use this as a traversal hint
instead of author date.
This commit is contained in:
Michael Forney 2022-03-17 01:41:44 +00:00
parent 8bd5be7c70
commit d55a64c905
2 changed files with 5 additions and 5 deletions

View file

@ -158,7 +158,7 @@ struct Objset {
struct Qelt {
Object *o;
vlong mtime;
vlong ctime;
int color;
};

View file

@ -349,9 +349,9 @@ qput(Objq *q, Object *o, int color)
}
q->heap[q->nheap].o = o;
q->heap[q->nheap].color = color;
q->heap[q->nheap].mtime = o->commit->mtime;
q->heap[q->nheap].ctime = o->commit->ctime;
for(i = q->nheap; i > 0; i = (i-1)/2){
if(q->heap[i].mtime < q->heap[(i-1)/2].mtime)
if(q->heap[i].ctime < q->heap[(i-1)/2].ctime)
break;
t = q->heap[i];
q->heap[i] = q->heap[(i-1)/2];
@ -378,9 +378,9 @@ qpop(Objq *q, Qelt *e)
m = i;
l = 2*i+1;
r = 2*i+2;
if(l < q->nheap && q->heap[m].mtime < q->heap[l].mtime)
if(l < q->nheap && q->heap[m].ctime < q->heap[l].ctime)
m = l;
if(r < q->nheap && q->heap[m].mtime < q->heap[r].mtime)
if(r < q->nheap && q->heap[m].ctime < q->heap[r].ctime)
m = r;
if(m == i)
break;