Skip to content

fix(githttp): store no pack for a push command that git refuses - #894

Open
ThomasK33 wants to merge 12 commits into
mainfrom
refused-push-stores-no-pack
Open

ThomasK33 wants to merge 12 commits into
mainfrom
refused-push-stores-no-pack

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Why

git refuses some push commands before the update hook runs: an object that the pack does not complete (a commit with a missing tree or parent, a random SHA, a tag at a missing target) and a shallow update (shallow update not allowed, for example a plain git push from a --depth 1 clone). git still hands such a command to pre-receive. The publication gate (preReceivePolicyGate in internal/githttp/hook.go) counted every command whose target was not in the main store as needing the pack, so the pack was uploaded and registered, no ref could ever point into it, and every repack carried its objects forward (the repack keeps the registered set, by design). Each refused shallow push with new objects left a quota-counted pack that nothing reclaims short of a repository purge. The code says the opposite: it must not publish a pack that "could only become a registered, unreachable, quota-consuming blob".

I reproduced it on main with a real node: shapes with a missing tree, a missing parent, a random SHA, a tag at a missing target, a real shallow push, a decoy (a create at a stored commit beside the refused command), and the atomic variant each left 1 registered pack and 1 blob. A policy denial, a branch at a blob, a no-force-push rewind, a hidden ref, a delete-only push and a quota denial leave none.

What changed

  • reachesUpdateHook answers "no" only when git exits 128 (a connectivity check that cannot read an object). Any other status says nothing about the command, so the gate publishes as before: a git without --exclude-hidden (before 2.39) exits 129 and behaves as it did, and a signal or an out-of-memory kill never refuses a push that git accepts. It runs git's own connectivity check (rev-list --objects --stdin --not --exclude-hidden=receive --all --quiet --alternate-refs, the call in git's connected.c) for a command's new value, in the hook's environment, which sees the quarantine.
  • The gate runs it for the first command that has no stored target, and stops asking once one command passes. A command that fails it never justifies publication. When no command needs the pack and some command git refuses, the push is refused before the upload, like a push that only policy-denied commands need (the same decoy rule). The pusher reads why: the quarantined pack is needed only by ref updates that git refuses (<ref>: its objects are incomplete, or the update is a shallow update), refusing pack publication. A refused push must not pass pre-receive, because git would then move the quarantined objects into the node's cache, where no registered pack holds them.
  • TestPackPublication_GitRefusedCommandStoresNothing (3 subtests: the shallow push, a commit with a missing tree, and the decoy) fails on main for the right reason (the count of pack rows and blobs) and passes here. TestReachesUpdateHookRefusesOnlyOnExit128 pins the exit-status rule.
  • The lane-schedule fingerprints are re-recorded, because preReceivePolicyGate is covered. The model does not describe the gate.

Tradeoff

A push whose first new command has a target that the main store lacks (every push that adds commits) now runs one more rev-list over that command's new objects. git did the same walk once before it ran the hook. A push of several refs pays it once, unless its first commands fail it: the gate stops at the first command that passes. A shallow push, or a push with a missing object, is now refused as a whole where git used to land its other refs (pre-receive refuses the push, like the existing decoy rule for a policy denial).

Scope

Not changed: the atomic stale-old refusal that registers its pack (it is a listed residual in the gate's comment), a stale compare-and-swap in a non-atomic push, and the D/F-doomed create. They fail after publication, for reasons that the gate does not model.

Verification

  • The new test fails on main (3 of 3) and passes. The full internal/githttp race lane (local backend, 841 s), gofmt, golangci-lint 2.15.0 (0 issues), the gitlimit lease audit, the darwin test build, the doc-link gate and both fingerprint gates pass. The PostgreSQL and S3-WAL lanes run in CI (this host has no docker).

Generated with xum • Model: anthropic:claude-sonnet-5-5 • Thinking: xhigh

git refuses a push command before the update hook runs when its objects
are incomplete (a missing tree, a missing parent, a random SHA, a tag at
a missing target) or when it is a shallow update, but it still passes the
command to pre-receive. The publication gate counted such a command as
needing the pack, so the pack was uploaded and registered, no ref pointed
into it, and every repack carried its objects forward. The gate now runs
git's own connectivity check for the first command that has no stored
target, and a command that fails it never justifies publication. A push
whose commands git refuses and no other command needs the pack is refused
before the upload, like a push that only policy-denied commands need.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I492f0a3b9407e77cfe4ac6464a467e3f43a97008
Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: Icfb038a419f8f0221eeee94ac6f914be03012449
…gate

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I8e3d2e74dc284bef083f354e46edb0ba69ee47ef
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T17:59:13.968283Z 1512fa8 Manual request
🔒 Security Review ✅ Completed 2026-11-16T18:01:52.705932Z 1512fa8 Manual request

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8faa6c5dbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/githttp/hook.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 8faa6c5dbc

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/githttp/hook.go Resolved
A connectivity check that cannot read an object exits 128. A git that
does not know --exclude-hidden (before 2.39) exits 129, and a signal or
an out-of-memory kill ends the check too. Those statuses say nothing about
the command, so the gate publishes as it did before and no push that git
accepts is refused. The refusal is a client-visible refusal, so the
pusher reads why the push stored nothing.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I8df39e20ce78f02f8d03e2c24e588790dab5fc81
Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I73ffc05cbf4b61525c02da34c08dbf54ea1c8f7c
Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: Ie48f212f900030abc3be5db9af7e4e3b4b6b910a
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: bc7553d08c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: bc7553d08c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

The gate comment says that a wholly allowed push is refused when only
git-refused commands need the pack, and that receive-pack runs one
combined check and then one check for each command. The wire
compatibility page lists refs that git refuses among the refs that make
the server decline a whole push. The no-replace test also covers the new
check.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I405b02b6752efc97ef906d4eb3e13e8371983210
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1512fa8adc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1512fa8adc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Only the lane-schedule sync commit line conflicted. Main moved it, so this
takes main's line and the next commit re-records it.

Change-Id: I26bf62e14bae9a571a410d93a0d35c839cd6469f
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Main moved the sync commit line in the same place. Only the line moves.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: If6d9dbcf7f01a570724e0c8a904801b6feb377be
…efused commands

A writer could send a push with hundreds of commands that name incomplete
histories. The publication gate then ran one git rev-list for each of them, and
each walked the same objects. The gate now asks git once for each distinct
target and stops asking after eight targets have failed. A push with more
failing targets than that publishes its pack as it did before the check.
git still refuses each of those refs.

The same change rewraps a comment, corrects a comment that promised a
message the git-refused refusal does not give, and adds a real signal to the
exit-status test.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I5260045b374c817b034e832a6926a29c9ed00d5d
…ectivity checks

The publication gate now asks git through a probe. The sync commit line and the
fingerprint of preReceivePolicyGate move with it, and the probe is covered.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I2623ed230422cc29d9a055365afa64b338e34899
staticcheck flagged the repeated call in one condition.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
<!-- xum-attribution: model=anthropic:claude-sonnet-5-5 thinking=xhigh -->

Change-Id: I4399c34c2fa711fc90100b764ac6c7aaaec05075

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant