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
---
upload-pack.c | 23 +++
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/upload-pack.c b/upload-pack.c
index 87c6722ea5..95c56dc027 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -28,7 +28,6 @@
#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)
@@ -334,36 +333,36 @@ 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, int with_flag, int assign_flag)
{
struct prio_queue work = { compare_commits_by_commit_date };
- prio_queue_put(, want);
+ prio_queue_put(, from);
while (work.nr) {
struct commit_list *list;
struct commit *commit = prio_queue_get();
- 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)
parse_object(>object.oid);
- if (commit->object.flags & REACHABLE)
+ if (commit->object.flags & TMP_MARK)
continue;
- commit->object.flags |= REACHABLE;
+ commit->object.flags |= TMP_MARK;
if (commit->date < oldest_have)
continue;
for (list = commit->parents; list; list = list->next) {
struct commit *parent = list->item;
- if (!(parent->object.flags & REACHABLE))
+ if (!(parent->object.flags & TMP_MARK))
prio_queue_put(, parent);
}
}
- want->object.flags |= REACHABLE;
- clear_commit_marks(want, REACHABLE);
+ from->object.flags |= TMP_MARK;
+ clear_commit_marks(from, TMP_MARK);
clear_prio_queue();
- return (want->object.flags & COMMON_KNOWN);
+ return (from->object.flags & assign_flag);
}
static int ok_to_give_up(void)
@@ -388,7 +387,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;
--
2.18.0.118.gd4f65b8d14