aboutsummaryrefslogtreecommitdiffstats
path: root/upload-pack.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-07-20 16:33:12 +0000
committerJunio C Hamano <gitster@pobox.com>2018-07-20 15:38:55 -0700
commit118be5785e2c8c90e7407bad4b4a33319ff47db3 (patch)
treec3396ba81746053f57e57ff2db28ee71bc515245 /upload-pack.c
parentupload-pack: refactor ok_to_give_up() (diff)
downloadgit-118be5785e2c8c90e7407bad4b4a33319ff47db3.tar.xz
git-118be5785e2c8c90e7407bad4b4a33319ff47db3.zip
upload-pack: generalize commit date cutoff
The ok_to_give_up() method uses the commit date as a cutoff to avoid walking the entire reachble set of commits. Before moving the reachable() method to commit-reach.c, pull out the dependence on the global constant 'oldest_have' with a 'min_commit_date' parameter. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 9fe19003c6b..427de461d85 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -337,7 +337,7 @@ static int got_oid(const char *hex, struct object_id *oid)
}
static int reachable(struct commit *from, unsigned int with_flag,
- unsigned int assign_flag)
+ unsigned int assign_flag, time_t min_commit_date)
{
struct prio_queue work = { compare_commits_by_commit_date };
@@ -355,7 +355,7 @@ static int reachable(struct commit *from, unsigned int with_flag,
if (commit->object.flags & REACHABLE)
continue;
commit->object.flags |= REACHABLE;
- if (commit->date < oldest_have)
+ if (commit->date < min_commit_date)
continue;
for (list = commit->parents; list; list = list->next) {
struct commit *parent = list->item;
@@ -372,11 +372,13 @@ static int reachable(struct commit *from, unsigned int with_flag,
/*
* Determine if every commit in 'from' can reach at least one commit
* that is marked with 'with_flag'. As we traverse, use 'assign_flag'
- * as a marker for commits that are already visited.
+ * as a marker for commits that are already visited. Do not walk
+ * commits with date below 'min_commit_date'.
*/
static int can_all_from_reach_with_flag(struct object_array *from,
unsigned int with_flag,
- unsigned int assign_flag)
+ unsigned int assign_flag,
+ time_t min_commit_date)
{
int i;
@@ -395,7 +397,8 @@ static int can_all_from_reach_with_flag(struct object_array *from,
from->objects[i].item->flags |= assign_flag;
continue;
}
- if (!reachable((struct commit *)from_one, with_flag, assign_flag))
+ if (!reachable((struct commit *)from_one, with_flag, assign_flag,
+ min_commit_date))
return 0;
}
return 1;
@@ -406,7 +409,8 @@ static int ok_to_give_up(void)
if (!have_obj.nr)
return 0;
- return can_all_from_reach_with_flag(&want_obj, THEY_HAVE, COMMON_KNOWN);
+ return can_all_from_reach_with_flag(&want_obj, THEY_HAVE,
+ COMMON_KNOWN, oldest_have);
}
static int get_common_commits(void)