summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-07-20 16:33:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-20 22:38:54 (GMT)
commitf044bb49add413915d699ca9e3458071dac6c731 (patch)
tree5965a6c1bb11dda272e2b9a91dcb2101469a52c6 /upload-pack.c
parent920f93ca1c005a81cfb88c87fca18de5e4bde8c5 (diff)
downloadgit-f044bb49add413915d699ca9e3458071dac6c731.zip
git-f044bb49add413915d699ca9e3458071dac6c731.tar.gz
git-f044bb49add413915d699ca9e3458071dac6c731.tar.bz2
upload-pack: make reachable() more generic
In anticipation of moving the reachable() method to commit-reach.c, modify the prototype to be more generic to flags known outside of upload-pack.c. Also rename 'want' to 'from' to make the statement more clear outside of the context of haves/wants negotiation. 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.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 4ca052d..5a639cb 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -336,17 +336,18 @@ static int got_oid(const char *hex, struct object_id *oid)
return 0;
}
-static int reachable(struct commit *want)
+static int reachable(struct commit *from, unsigned int with_flag,
+ unsigned int assign_flag)
{
struct prio_queue work = { compare_commits_by_commit_date };
- prio_queue_put(&work, want);
+ prio_queue_put(&work, from);
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;
+ if (commit->object.flags & with_flag) {
+ from->object.flags |= assign_flag;
break;
}
if (!commit->object.parsed)
@@ -362,10 +363,10 @@ static int reachable(struct commit *want)
prio_queue_put(&work, parent);
}
}
- want->object.flags |= REACHABLE;
- clear_commit_marks(want, REACHABLE);
+ from->object.flags |= REACHABLE;
+ clear_commit_marks(from, REACHABLE);
clear_prio_queue(&work);
- return (want->object.flags & COMMON_KNOWN);
+ return (from->object.flags & assign_flag);
}
static int ok_to_give_up(void)
@@ -390,7 +391,7 @@ static int ok_to_give_up(void)
want_obj.objects[i].item->flags |= COMMON_KNOWN;
continue;
}
- if (!reachable((struct commit *)want))
+ if (!reachable((struct commit *)want, THEY_HAVE, COMMON_KNOWN))
return 0;
}
return 1;