Optimize validate_sha()
with --max-count=1
#111
Merged
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.
Optimize the
validate_sha()
function with--max-count=1
to prevent printing the git log of every single commit. See the "Commit Limiting" section ofgit-log
's man pageThis makes the function near instant.
Currently, running
time git log main > /dev/null
takes about ~1s second for me on the CPython repo, whiletime git log --max-count=1 main > /dev/null
(with or without the-r
flag) only takes about 0.003s.Additionally, if you've cloned the CPython repo using a blobless clone (e.g. with
git clone --filter=blob:none https://github.com/python/cpython.git
), doing agit log -r
takes a very long time (almost an hour for me on a slow internet connection!), since the-r
flag seems to force downloading a blob for every single commit, which makes a blobless clone kind of useless.