Repository navigation
syncer, translate: sync a SHA256 repository back to its SHA1 original - #152
Merged
Merged
Conversation
After a convert-sha256 cutover, the original SHA1 repository can stay as a read-only reference. When the source is SHA256 and the target SHA1, sync translates objects instead of relaying packs, and pushes the SHA1 commits a direct commit would have produced. Objects convert as git's object-file-convert.c converts them for extensions.compatObjectFormat. Commits keep both gpgsig and gpgsig-sha256, mergetag headers are converted, and tag signatures swap between body and header. A differential test checks every object shape t1016 builds against the hashes git itself computes, in both directions. History from before the cutover keeps its original hashes through the source's refs/notes/sha1-origin. Each sync records what it wrote in the target's refs/notes/sha256-origin, in one atomic push with the refs when the target supports it. Before pushing, it checks that the target holds the commits the new history builds on. An existing tag is left alone, and a branch written directly on the SHA1 side blocks the sync. Replicate, bootstrap, prune, all-refs and force are refused with ErrObjectFormatMismatch. Every other format mismatch fails as before. convert-sha256 now uses the same conversion. It keeps signatures and leaves messages alone unless --rewrite-messages is given. --no-rewrite-messages is deprecated. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M89K6SJ49FVR8E5P3WXRXARW
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 412a480. Configure here.
Address the review findings on the back-sync. Make the atomic push opt-in with --atomic. It sends every ref update and the origin notes in one receive-pack request, which is never split, so it ignores --target-max-ref-updates by design. It fails up front against a target without atomic support, and outside a translated sync. Write refs/notes/sha256-origin as one parentless commit that each sync replaces. Reading the notes no longer fetches every earlier snapshot, which grew quadratically with the number of syncs. The fetch is now bounded by the materialized object limit. Check that the target holds the commits the translation builds on by negotiating as a fetch does: want an advertised tip and offer those commits as haves. upload-pack acknowledges the ones it holds and sends no pack. Stateful protocol v0 and v1, as over SSH, refuse a want no ref points at, which made a tag on a pre-cutover commit fail the check. v2 uses wait-for-done, and falls back to wanting the commits when the server does not advertise it. The notes ref counts as a tip, so a target where only the notes landed can still be checked. Add --retranslate-tags to repair origin notes for tags the target already has, as when a non-atomic push landed a tag but the target refused its notes. Tags are never changed. Notes are only written for commits the target will hold. Refuse best-effort runs when translating, since a rejected notes ref went unreported. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M89S8JM8B7RBPQ28NEMBVPBR Signed-off-by: Paulo Gomes <paulo@entire.io>
Packages whose tests run the git binary now isolate it from the global and system config in TestMain, as the syncer tests already do. A host with commit.gpgsign set made the back-sync tests wait on a signing agent. Pin uploadpack.allowReachableSHA1InWant and allowAnySHA1InWant to false on the repositories the target possession check runs against, so the tests keep proving it works with upload-pack's defaults. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8AZPN4HPTSQP292RTS09FG8
Released convert-sha256 versions decoded and re-encoded trees, which normalized modes such as 100011 and 040000. The SHA256 tree of a commit they converted then does not translate back to the SHA1 tree the target holds. Back-sync left every object in a pre-cutover commit's tree out of the push, so a new commit reusing such a tree failed with "missing necessary objects". Convert each pre-cutover commit the new history builds on back to SHA1 and compare it with the recorded hash. Where it differs, push the trees the new commits share with it and leave out only its blobs, which convert unchanged. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8BKQQPDZZKQA0AMYR6J43T3
upload-pack stops acknowledging haves once it has found enough common commits to send a pack. With A, B and C on one line of history and C wanted, offering A and B acknowledges only the first, over v1 and v2. HasCommits then reported a commit the target holds as missing, and back-sync refused a valid sync. Offer each commit the first round left unacknowledged again, on its own. The negotiation test now runs over git http-backend as well as the ssh stand-in and asks about two commits on one line of history. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8BQQ19JFEFMYN03978BN6KP
A non-atomic push can land refs/notes/sha256-origin while the target refuses the branch, and the target can later prune the commit the note records. Back-sync trusted every note as a seed, so the target check failed on that commit on every later run. Track the seeds only the target's notes record. When the target lacks one, drop it and translate again, which reproduces the same hash, and push the commit. A missing pre-cutover commit still fails the run. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8BQQ61VAC44WBQV8RJWNS21
- Leave tags the target already has out of the source fetch unless RetranslateTags translates them. Their history counted toward the object limit and could block an unrelated branch update. - Check the target holds the commits the new history builds on in a plan or dry run too, so a plan no longer reports an update the sync would refuse. - Strip control characters from the remote ERR text in the negotiation and fetch parsers before it reaches an error. - Drop refs/tags/converted/* by source name as well as target name, so a mapping cannot sync an attestation tag under another name. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8BVNAPH5CEW16Q53KEFZQJA
- Keep a remote ERR message to one line. sanitize.Text kept newlines and C1 controls such as U+009B, so a server could still forge a second line or drive a terminal. All four ERR sites now go through one helper that uses sanitize.Line. - Offer the commits upload-pack left unacknowledged again as one batch, until a request acknowledges none, instead of one request each. v2 leaves out a have whose child it read earlier in the same request, so a chain of 20 commits took 11 requests and now takes 4. - Keep the source's sha1-origin mapping when the target's notes also map the commit. A stale target note used to replace it and fail every run. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8C0PBMQ9SFGJ5PR14XKM852
HasCommits offered the unacknowledged commits again for as long as a round acknowledged anything. A server that acknowledged only hashes it was not offered, such as the wanted tip, was asked again until the context ended, and those hashes ended up in the result. Count only acknowledgments of offered commits, and stop once a round adds none. The commits left are reported missing. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 01M8C3GJ10MPH1FBZNA79WXKJ6
nodo
approved these changes
Nov 27, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

After a convert-sha256 cutover, the original SHA1 repository can stay as a read-only reference. When the source is SHA256 and the target SHA1, sync translates objects instead of relaying packs, and pushes the SHA1 commits a direct commit would have produced.
Objects convert as git's object-file-convert.c converts them for extensions.compatObjectFormat. Commits keep both gpgsig and gpgsig-sha256, mergetag headers are converted, and tag signatures swap between body and header. A differential test checks every object shape t1016 builds against the hashes git itself computes, in both directions.
History from before the cutover keeps its original hashes through the source's refs/notes/sha1-origin. Each sync records what it wrote in the target's refs/notes/sha256-origin, in one atomic push with the refs when the target supports it. Before pushing, it checks that the target holds the commits the new history builds on. An existing tag is left alone, and a branch written directly on the SHA1 side blocks the sync. Replicate, bootstrap, prune, all-refs and force are refused with ErrObjectFormatMismatch. Every other format mismatch fails as before.
convert-sha256 now uses the same conversion. It keeps signatures and leaves messages alone unless --rewrite-messages is given. --no-rewrite-messages is deprecated.
Note
High Risk
Changes core sync/push behavior and object conversion (signatures, notes, fast-forward rules); incorrect translation or push ordering could corrupt reference repos or break verification.
Overview
Adds SHA256 → SHA1 back-sync: when the source advertises
object-format=sha256and the target is SHA1,syncnow translates objects (instead of relaying packs or failing) so the original repo can stay as a read-only reference afterconvert-sha256. Translation uses a newinternal/translatepackage that mirrors git'sobject-file-convert.c(signatures andmergetagpreserved; round-trip to SHA1 bytes). The sync path seeds fromrefs/notes/sha1-origin/refs/notes/sha256-origin, verifies the target has pre-cutover commits, blocks branches written on the SHA1 side, skips existing tags, and pushes refs plus notes atomically when supported (PushObjectsAtomic). Replicate, bootstrap, prune,--all-refs, and force flags are refused for this pair.convert-sha256is switched to the same conversion path: signatures are no longer stripped, message hash rewrites are opt-in via--rewrite-messages(default off;--no-rewrite-messagesdeprecated), and--jsondropssignaturesStripped. Docs, changelog, unit/git-compat tests, and an HTTP-backend back-sync e2e cover the workflow.Reviewed by Cursor Bugbot for commit 412a480. Configure here.