Skip to content

commit-reach: remove get_reachable_subset()#2141

Closed
spkrka wants to merge 1 commit into
gitgitgadget:masterfrom
spkrka:krka/remove-get-reachable-subset
Closed

commit-reach: remove get_reachable_subset()#2141
spkrka wants to merge 1 commit into
gitgitgadget:masterfrom
spkrka:krka/remove-get-reachable-subset

Conversation

@spkrka

@spkrka spkrka commented Jun 8, 2026

Copy link
Copy Markdown

This removes get_reachable_subset() and converts its only caller
to use tips_reachable_from_bases() directly. Both answer the same
category-2 reachability question ("which tips are reachable from
these bases?") but were introduced years apart and never consolidated.

On the no-commit-graph tradeoff: without generation numbers, the
date-ordered BFS in get_reachable_subset() can be more disciplined
than DFS since it naturally stays near the top of the graph. But
this only matters for repositories that are both large enough for
the difference to be measurable and missing a commit-graph -- a
combination that would already struggle for many other reasons.
The fix there is to enable the commit-graph, not to maintain two
implementations of the same reachability query.

Notes for reviewers:

  • The flag in remote.c changes from 1 to TMP_MARK because
    tips_reachable_from_bases() uses SEEN (bit 0) internally.
    TMP_MARK is already used earlier in the same function and
    is cleared before the reachability block.

  • The sent_tips array is converted to a commit_list to match
    the tips_reachable_from_bases() API. This is O(n) list-node
    allocations, negligible compared to the graph walk.

  • Test helper and test names rename from get_reachable_subset
    to tips_reachable_from_bases to match the function being
    exercised.

cc: Derrick Stolee stolee@gmail.com

@gitgitgadget

gitgitgadget Bot commented Jun 8, 2026

Copy link
Copy Markdown

There is an issue in commit 538378a:
commit-reach: remove get_reachable_subset()

  • Commit not signed off

@spkrka spkrka force-pushed the krka/remove-get-reachable-subset branch from 538378a to e327567 Compare June 8, 2026 08:02
@spkrka

spkrka commented Jun 8, 2026

Copy link
Copy Markdown
Author

/cc @derrickstolee

@spkrka spkrka marked this pull request as ready for review June 8, 2026 08:21
@Rube2024actual

Copy link
Copy Markdown

There is an issue in commit 538378a:
commit-reach: remove get_reachable_subset()

  • Commit not signed off

https://gitgitgadget.github.io/```


@spkrka spkrka force-pushed the krka/remove-get-reachable-subset branch 3 times, most recently from ee9fc15 to d9822cf Compare June 9, 2026 11:19
get_reachable_subset() and tips_reachable_from_bases() answer the
same question: given a set of bases and a set of tips, which tips
are reachable from at least one base?

get_reachable_subset() was introduced in fcb2c07 (2018-11-02)
for add_missing_tags() in remote.c. tips_reachable_from_bases()
was added in cbfe360 (2023-03-20) as part of the ahead-behind
series. The two were never consolidated.

With a commit-graph, tips_reachable_from_bases() can have an edge:
its DFS raises the generation floor as lower targets are found,
pruning more aggressively than the static floor in
get_reachable_subset(). Without generation numbers, some edge cases
may be slower with DFS instead of BFS since the date-ordered
prio_queue naturally stays near the top of the graph, but this
should not matter in practice -- worst case both visit the full
graph down from the bases.

The flag in remote.c changes from 1 (bit 0) to TMP_MARK (bit 4)
because tips_reachable_from_bases() uses SEEN (bit 0) internally.
TMP_MARK is already used for deduplication earlier in the same
function and is cleared before the reachability check.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
@spkrka spkrka force-pushed the krka/remove-get-reachable-subset branch from d9822cf to df8e2de Compare June 9, 2026 12:34
@spkrka spkrka closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants