aboutsummaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-10-04 15:37:15 -0700
committerJunio C Hamano <gitster@pobox.com>2012-10-04 15:49:39 -0700
commitd866924a080215dd276c510abf255a8929b55643 (patch)
treefe0ee5b7e358b77ab0ccfd32b9e29f21170f147c /commit.c
parentf37d3c755209234acfc2ca280027ebdab8e9ea8a (diff)
downloadgit-d866924a080215dd276c510abf255a8929b55643.tar.gz
git-d866924a080215dd276c510abf255a8929b55643.tar.xz
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 <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index 69af37014..47027f68e 100644
--- a/commit.c
+++ b/commit.c
@@ -581,6 +581,7 @@ static struct commit *interesting(struct commit_list *list)
return NULL;
}
+/* all input commits in one and twos[] must have been parsed! */
static struct commit_list *paint_down_to_common(struct commit *one, int n, struct commit **twos)
{
struct commit_list *list = NULL;
@@ -589,6 +590,8 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n, struc
one->object.flags |= PARENT1;
commit_list_insert_by_date(one, &list);
+ if (!n)
+ return list;
for (i = 0; i < n; i++) {
twos[i]->object.flags |= PARENT2;
commit_list_insert_by_date(twos[i], &list);
@@ -709,6 +712,8 @@ static int remove_redundant(struct commit **array, int cnt)
redundant = xcalloc(cnt, 1);
filled_index = xmalloc(sizeof(*filled_index) * (cnt - 1));
+ for (i = 0; i < cnt; i++)
+ parse_commit(array[i]);
for (i = 0; i < cnt; i++) {
struct commit_list *common;