Repository navigation
Conversation
"git merge-base" without --all stops the walk early when it finds a merge base in the generation-ordered region of the commit-graph. This optimization does not apply when the merge base is found outside that region, e.g. among commits not yet in the commit-graph. Generalize it to stop once a merge base has been found and the next queued commit is in the ordered region, wherever the merge base was found. This is safe because no remaining commit can be a descendant of a candidate found so far: no commit in the ordered region can descend from one outside it, and descendants of a candidate inside it were visited first. Any redundancy among the candidates already found is handled by remove_redundant(). The main benefit is simpler and broader logic. The scenario is unlikely to matter much in practice, so no benchmark is included. Add a test with the merge base just outside the commit-graph. Walk steps in that test, before and after this change: commit-graph before after none 21 21 full 11 3 half 15 11 no-gdat 18 3 No further tests are added, as the ways this exit condition can go wrong are already well covered. This was verified with simple mutation testing: - Stopping at the first result even outside the ordered region, before a descendant candidate is found: the "clock skew, v1 commit-graph" test in t6600, and "merge-base G H" and "unsynchronized clocks" in t6010. - Stopping at the ceiling without a result: t5318, t6099 and t6600. - Stopping early when --all is given: t5318 and t6600. - Not stopping at all: the new test, through its step counts. Signed-off-by: Kristofer Karlsson <krka@spotify.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small cleanup follow-up to my previous work on fast-exit
merge-base. It's not really less code, but it generalize the fast-exit
rule to apply to slightly more scenarios, though they are somewhat
unlikely to trigger in practice.
So the main value here is not any type of practical performance
boost, it's rather somewhat of a code hygiene fix.
That said, if this just feels like churning the code
for no reason, I don't mind dropping it instead.