aboutsummaryrefslogtreecommitdiffstats
path: root/upload-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-17 13:53:52 -0700
committerJunio C Hamano <gitster@pobox.com>2018-09-17 13:53:52 -0700
commit1b7a91da71d42759dfb83fa3a17be54ad01f0132 (patch)
tree921c80479f0f12a95114b0b32f6fdfa928f170c8 /upload-pack.c
parent4d6d6ef1fcce0e7d1fd2d3d38c2372998a105e96 (diff)
parent6621c838743812aaba96e55cfec8524ea1144c2d (diff)
downloadgit-1b7a91da71d42759dfb83fa3a17be54ad01f0132.tar.gz
Merge branch 'ds/reachable'
The code for computing history reachability has been shuffled, obtained a bunch of new tests to cover them, and then being improved. * ds/reachable: commit-reach: correct accidental #include of C file commit-reach: use can_all_from_reach commit-reach: make can_all_from_reach... linear commit-reach: replace ref_newer logic test-reach: test commit_contains test-reach: test can_all_from_reach_with_flags test-reach: test reduce_heads test-reach: test get_merge_bases_many test-reach: test is_descendant_of test-reach: test in_merge_bases test-reach: create new test tool for ref_newer commit-reach: move can_all_from_reach_with_flags upload-pack: generalize commit date cutoff upload-pack: refactor ok_to_give_up() upload-pack: make reachable() more generic commit-reach: move commit_contains from ref-filter commit-reach: move ref_newer from remote.c commit.h: remove method declarations commit-reach: move walk methods from commit.c
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c58
1 files changed, 5 insertions, 53 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 82b393ec31..62a1000f44 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -24,13 +24,13 @@
#include "quote.h"
#include "upload-pack.h"
#include "serve.h"
+#include "commit-reach.h"
/* Remember to update object flag allocation in object.h */
#define THEY_HAVE (1u << 11)
#define OUR_REF (1u << 12)
#define WANTED (1u << 13)
#define COMMON_KNOWN (1u << 14)
-#define REACHABLE (1u << 15)
#define SHALLOW (1u << 16)
#define NOT_SHALLOW (1u << 17)
@@ -337,64 +337,16 @@ static int got_oid(const char *hex, struct object_id *oid)
return 0;
}
-static int reachable(struct commit *want)
-{
- struct prio_queue work = { compare_commits_by_commit_date };
-
- prio_queue_put(&work, want);
- while (work.nr) {
- struct commit_list *list;
- struct commit *commit = prio_queue_get(&work);
-
- if (commit->object.flags & THEY_HAVE) {
- want->object.flags |= COMMON_KNOWN;
- break;
- }
- if (!commit->object.parsed)
- parse_object(the_repository, &commit->object.oid);
- if (commit->object.flags & REACHABLE)
- continue;
- commit->object.flags |= REACHABLE;
- if (commit->date < oldest_have)
- continue;
- for (list = commit->parents; list; list = list->next) {
- struct commit *parent = list->item;
- if (!(parent->object.flags & REACHABLE))
- prio_queue_put(&work, parent);
- }
- }
- want->object.flags |= REACHABLE;
- clear_commit_marks(want, REACHABLE);
- clear_prio_queue(&work);
- return (want->object.flags & COMMON_KNOWN);
-}
-
static int ok_to_give_up(void)
{
- int i;
+ uint32_t min_generation = GENERATION_NUMBER_ZERO;
if (!have_obj.nr)
return 0;
- for (i = 0; i < want_obj.nr; i++) {
- struct object *want = want_obj.objects[i].item;
-
- if (want->flags & COMMON_KNOWN)
- continue;
- want = deref_tag(the_repository, want, "a want line", 0);
- if (!want || want->type != OBJ_COMMIT) {
- /* no way to tell if this is reachable by
- * looking at the ancestry chain alone, so
- * leave a note to ourselves not to worry about
- * this object anymore.
- */
- want_obj.objects[i].item->flags |= COMMON_KNOWN;
- continue;
- }
- if (!reachable((struct commit *)want))
- return 0;
- }
- return 1;
+ return can_all_from_reach_with_flag(&want_obj, THEY_HAVE,
+ COMMON_KNOWN, oldest_have,
+ min_generation);
}
static int get_common_commits(void)