Skip to content

fix: support SHA-256 zero OIDs in pre-push#3721

Closed
tianrking wants to merge 1 commit into
pre-commit:mainfrom
tianrking:agent/support-sha256-zero-oids
Closed

fix: support SHA-256 zero OIDs in pre-push#3721
tianrking wants to merge 1 commit into
pre-commit:mainfrom
tianrking:agent/support-sha256-zero-oids

Conversation

@tianrking

Copy link
Copy Markdown

Summary

  • recognize the zero object ID used by SHA-256 repositories in pre-push input
  • cover branch deletion for both SHA-1 and SHA-256 object formats

Root cause

The pre-push parser only recognized Git's 40-character SHA-1 zero object ID. In SHA-256 repositories, deletion records use a 64-character zero ID, so the hook attempted to diff against an invalid revision instead of skipping the deletion.

Fixes #3664

Validation

  • python -m pytest tests/commands/hook_impl_test.py -q (45 passed)

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