Skip to content

use git cat-file -e instead of git rev-list in _rev_exists#3605

Open
ptarjan wants to merge 11 commits into
pre-commit:mainfrom
ptarjan:rev-list
Open

use git cat-file -e instead of git rev-list in _rev_exists#3605
ptarjan wants to merge 11 commits into
pre-commit:mainfrom
ptarjan:rev-list

Conversation

@ptarjan

@ptarjan ptarjan commented Dec 26, 2025

Copy link
Copy Markdown

fixes #3604

https://git-scm.com/docs/git-cat-file

-e
Exit with zero status if <object> exists and is a valid object. If <object> is of an invalid format, exit with non-zero status and emit an error on stderr.

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes output spew on missing / invalid revisions

Comment thread pre_commit/commands/hook_impl.py Outdated
@ptarjan

ptarjan commented Dec 26, 2025

Copy link
Copy Markdown
Author

How is that different than the current implementation?

~/github/pre-commit rev-list $ git rev-list --quiet abcde --
fatal: bad revision 'abcde'
~/github/pre-commit rev-list $ git cat-file -e abcde
fatal: Not a valid object name abcde

@ptarjan ptarjan requested a review from asottile December 26, 2025 22:11
Comment thread pre_commit/commands/hook_impl.py Outdated
Comment thread pre_commit/commands/hook_impl.py
@ptarjan

ptarjan commented Dec 26, 2025 via email

Copy link
Copy Markdown
Author

@asottile

Copy link
Copy Markdown
Member

do you actually understand what not 0 does? I'm more and more convinced you're just regurgitating llm nonsense and wasting my time. a human would have just changed the command and called it a day but instead we're somehow 10 commits deep

@asottile

Copy link
Copy Markdown
Member

How is that different than the current implementation?

~/github/pre-commit rev-list $ git rev-list --quiet abcde --
fatal: bad revision 'abcde'
~/github/pre-commit rev-list $ git cat-file -e abcde
fatal: Not a valid object name abcde

You're absolutely right!

@ptarjan ptarjan requested a review from asottile December 27, 2025 06:27
@ptarjan

ptarjan commented Dec 29, 2025

Copy link
Copy Markdown
Author

Is there anything else on this PR you need from me?

@ptarjan

ptarjan commented Jan 25, 2026

Copy link
Copy Markdown
Author

Is there anything else on this PR you need from me?

Would you prefer anything else from me to get this merged?

@rmawatson

Copy link
Copy Markdown

@ptarjan - just to be understand, why was the PR here abandoned in favour of this one?

@ptarjan

ptarjan commented Feb 12, 2026

Copy link
Copy Markdown
Author

@asottile didn't want a PR generated by Claude to be included in his repo so I generated this one by hand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

git rev-list --quiet is slow in a large repo

3 participants