Skip to content

Handle SHA-256 zero OIDs in pre-push - #3738

Closed
AleksZyro wants to merge 1 commit into
pre-commit:mainfrom
AleksZyro:fix-sha256-pre-push-delete
Closed

Handle SHA-256 zero OIDs in pre-push#3738
AleksZyro wants to merge 1 commit into
pre-commit:mainfrom
AleksZyro:fix-sha256-pre-push-delete

Conversation

@AleksZyro

Copy link
Copy Markdown

Fixes #3664.

Git emits 64-character zero OIDs in SHA-256 repositories. The pre-push hook only recognised the SHA-1 zero OID, so deletion pushes could fall through into revision range handling instead of being skipped.

This recognises all-zero OIDs for both SHA-1 and SHA-256, and adds a regression test for deleting a branch from a SHA-256 repository.

Tested with:

python -m pytest tests/commands/hook_impl_test.py::test_run_ns_pre_push_deleting_branch tests/commands/hook_impl_test.py::test_run_ns_pre_push_deleting_branch_sha256 tests/commands/hook_impl_test.py::test_hook_impl_main_noop_pre_push -q
python -m pytest tests/commands/hook_impl_test.py -q -k "pre_push"

@asottile asottile closed this Aug 5, 2026
@pre-commit pre-commit locked as spam and limited conversation to collaborators Aug 5, 2026
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