Skip to content

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

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

Handle SHA-256 zero OIDs in pre-push#3671
ShipItAndPray wants to merge 1 commit into
pre-commit:mainfrom
ShipItAndPray:fix-3664-sha256-zero-oid

Conversation

@ShipItAndPray

Copy link
Copy Markdown

Summary

  • treat any all-zero object ID as the null push sentinel in pre-push
  • keep branch deletion short-circuits working for SHA-256 repos
  • add regression coverage for 64-zero delete lines in both _run_ns() and hook_impl()

Closes #3664.

Validation

  • baseline repro on current main: SHA-256 pre-push delete exited non-zero and raised CalledProcessError from git diff ...<64 zeros>
  • .venv/bin/python -m pytest tests/commands/hook_impl_test.py -k 'sha256_zero_oid' -q
  • .venv/bin/python -m pytest tests/commands/hook_impl_test.py -k 'pre_push' -q
  • direct SHA-256 shell repro after fix: exit status 0

Gates

  • E1 baseline repro exists: yes
  • E2 new regression tests fail on baseline: yes
  • E3 new regression tests pass after fix: yes
  • E4 nearby targeted suite passes: yes
  • E5 diff localized to pre_commit/commands/hook_impl.py and tests/commands/hook_impl_test.py: yes

@asottile

Copy link
Copy Markdown
Member

ai slop is not acceptable

@asottile asottile closed this Apr 27, 2026
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.

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

3 participants