Skip to content

Commit f044bb4

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 920f93c commit f044bb4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

upload-pack.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,18 @@ static int got_oid(const char *hex, struct object_id *oid)
336336
return 0;
337337
}
338338

339-
static int reachable(struct commit *want)
339+
static int reachable(struct commit *from, unsigned int with_flag,
340+
unsigned int assign_flag)
340341
{
341342
struct prio_queue work = { compare_commits_by_commit_date };
342343

343-
prio_queue_put(&work, want);
344+
prio_queue_put(&work, from);
344345
while (work.nr) {
345346
struct commit_list *list;
346347
struct commit *commit = prio_queue_get(&work);
347348

348-
if (commit->object.flags & THEY_HAVE) {
349-
want->object.flags |= COMMON_KNOWN;
349+
if (commit->object.flags & with_flag) {
350+
from->object.flags |= assign_flag;
350351
break;
351352
}
352353
if (!commit->object.parsed)
@@ -362,10 +363,10 @@ static int reachable(struct commit *want)
362363
prio_queue_put(&work, parent);
363364
}
364365
}
365-
want->object.flags |= REACHABLE;
366-
clear_commit_marks(want, REACHABLE);
366+
from->object.flags |= REACHABLE;
367+
clear_commit_marks(from, REACHABLE);
367368
clear_prio_queue(&work);
368-
return (want->object.flags & COMMON_KNOWN);
369+
return (from->object.flags & assign_flag);
369370
}
370371

371372
static int ok_to_give_up(void)
@@ -390,7 +391,7 @@ static int ok_to_give_up(void)
390391
want_obj.objects[i].item->flags |= COMMON_KNOWN;
391392
continue;
392393
}
393-
if (!reachable((struct commit *)want))
394+
if (!reachable((struct commit *)want, THEY_HAVE, COMMON_KNOWN))
394395
return 0;
395396
}
396397
return 1;

0 commit comments

Comments
 (0)