FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Accept SHA-256 all-zero OIDs in pre-push deletion detection by Eryx-Z · Pull Request #3781 · pre-commit/pre-commit · GitHub

Repository navigation

Accept SHA-256 all-zero OIDs in pre-push deletion detection - #3781

Closed
Eryx-Z wants to merge 1 commit into
pre-commit:mainfrom
Eryx-Z:fix/3664-sha256-zero-oid
Closed

Eryx-Z wants to merge 1 commit into
pre-commit:mainfrom
Eryx-Z:fix/3664-sha256-zero-oid

Conversation

Eryx-Z commented Oct 17, 2026

Copy link
Copy Markdown

Summary

pre_commit/commands/hook_impl.py hardcoded Z40 = '0' * 40 for deletion / new-branch detection on pre-push. SHA-256 repositories emit a 64-character zero OID, so git push --delete fell through into git diff against the zero OID and failed.

Accept an all-zero OID of length 40 or 64 via _is_zero_oid().

Fixes #3664.

Test plan

  • Unit tests for _is_zero_oid
  • Existing SHA-1 deletion test still passes
  • New SHA-256 deletion stdin case returns None (noop) like SHA-1

Git SHA-256 repos emit a 64-character zero OID for deletion pushes.
Hardcoding only the SHA-1 40-zero form made `git push --delete` fail
with Invalid revision range errors.

Fixes pre-commit#3664.
asottile closed this Oct 17, 2026
pre-commit locked as spam and limited conversation to collaborators Oct 17, 2026
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Z40 = '0' * 40 hardcoding breaks git push --delete on SHA-256 repos

2 participants


Back | FazBrowse Home | New Git URL