Skip to content

Commit d866924

Browse files
committed
paint_down_to_common(): parse commit before relying on its timestamp
When refactoring the merge-base computation to reduce the pairwise O(n*(n-1)) traversals to parallel O(n) traversals, the code forgot that timestamp based heuristics needs each commit to have been parsed. This caused an empty "git pull" to spend cycles, traversing the history all the way down to 0 (because an unparsed commit object has 0 timestamp, and any other commit object with positive timestamp will be processed for its parents, all getting parsed), only to come up with a merge message to be used. Signed-off-by: Junio C Hamano <[email protected]>
1 parent f37d3c7 commit d866924

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

commit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ static struct commit *interesting(struct commit_list *list)
581581
return NULL;
582582
}
583583

584+
/* all input commits in one and twos[] must have been parsed! */
584585
static struct commit_list *paint_down_to_common(struct commit *one, int n, struct commit **twos)
585586
{
586587
struct commit_list *list = NULL;
@@ -589,6 +590,8 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, struc
589590

590591
one->object.flags |= PARENT1;
591592
commit_list_insert_by_date(one, &list);
593+
if (!n)
594+
return list;
592595
for (i = 0; i < n; i++) {
593596
twos[i]->object.flags |= PARENT2;
594597
commit_list_insert_by_date(twos[i], &list);
@@ -709,6 +712,8 @@ static int remove_redundant(struct commit **array, int cnt)
709712
redundant = xcalloc(cnt, 1);
710713
filled_index = xmalloc(sizeof(*filled_index) * (cnt - 1));
711714

715+
for (i = 0; i < cnt; i++)
716+
parse_commit(array[i]);
712717
for (i = 0; i < cnt; i++) {
713718
struct commit_list *common;
714719

0 commit comments

Comments
 (0)