gitproto: sync SHA-256 repositories #151
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #151"
general
weight: 0.35
pjbgf
Summary
git-sync could not sync SHA-256 repositories. Protocol v2 treats a client that omits
object-formatas SHA-1, so a SHA-256 server rejects everyls-refsandfetchfrom git-sync. Real git rejects both outright; a server that only checks onfetchanswers it withobject-format mismatch: client did not declare object-format, server "sha256". Past that, git-sync assumed SHA-1 in several more places. Each fix below exposed the next:v1 upload-pack requests declare the advertised
object-formattoo.git-sync relays the source's ids and packs unchanged, so it cannot sync between formats. Sync, plan, replicate and bootstrap between a SHA-1 and a SHA-256 repository now stop once both formats are known, before fetching anything, with an error that names both and wraps
ErrObjectFormatMismatch. Probe skips that check, so it still shows what each endpoint advertised. A remote advertising a format other thansha1orsha256is rejected withErrUnsupportedObjectFormatas soon as its advertisement is read, before any of its ids are decoded. Both sentinels are exported from the root package.Requests to SHA-1 repositories are unchanged, except that a server advertising
object-format=sha1now gets it echoed back, as real git does.Evidence
All end-to-end tests run against real
git http-backend.New
TestReplicate_GitHTTPBackendSHA256: replicate mode with prune and tags, SHA-256 source and target. A bootstrap into an empty target, then a fast-forward, a new branch and a branch deletion.replicate failed: list source refs: read pktline header: EOF(git rejects thels-refs)bootstrap execute: push target refs: decode report-status: unexpected EOFTestReplicate_GitHTTPBackendResumeAfterTrunkLandedgains two SHA-256 cases (empty target, and trunk already on the target):fetch bootstrap commit parents …: parse packfile: malformed pack file: checksum mismatchNew
TestReplicate_GitHTTPBackendSplitsTrunkAcrossPushes(sha1 + sha256): three ~150 KB commits against a 325 KB push limit, so the trunk must be split across pushes.bootstrap checkpoint exceeds target pack limit and cannot be subdivided further: … http 413, because the parent parser dropped every 64-hex parent and the planner saw a one-commit chainThe same test captures
BootstrapLoggerand requires every checkpoint to logobserver_failed=false. Before the fix, a SHA-256 checkpoint that landed loggedobserver_failed=true. Without theSourceObjectFormatwiring in syncer, the test fails.TestRun_GitHTTPBackendSync(default sync mode) now runs for sha1 and sha256:fetch to store: update object storage: malformed pack file: checksum mismatchNew
TestRun_GitHTTPBackendSyncObjectFormatMismatch(sha1→sha256 and sha256→sha1) asserts the mismatch error from sync, plan, replicate and bootstrap, that no fetch reaches the source, and that Probe still returns the source refs and both endpoints'object-format:push target refs: decode report-status: unexpected EOFobject formats: source and target object formats differ: source is sha1, target is sha256; …, with no fetchNew
mise run test:git-http-backend:sha256runs every git-http-backend test withGIT_DEFAULT_HASH=sha256; all pass. Both backend tasks run with-count=1: only the git subprocess readsGIT_DEFAULT_HASH, so Go's test cache would otherwise replay one format's result for the other.TestV1AdvertisementRejectsUnsupportedObjectFormatuses asha512advertisement with 128-hex ids, on the source and the target, in eight layouts: plain,version 1first, a first ref line over 4 KiB, one near the 65520-byte pkt-line limit,version 1followed by a long line, and three without the smart-HTTP banner (as SSH and remote helpers send):cannot read hash, invalid size: 128, notErrUnsupportedObjectFormat(plain layout first; the other four after the first fix)ErrUnsupportedObjectFormatin every layout; sha1 and sha256 advertisements still decode in every layoutWithout a banner, a valid advertisement of any format whose first ref line is over 4 KiB used to fail with
peek pktline: bufio: buffer full, onmaintoo: the banner check peeked the whole first packet. It now peeks only# service=.Unit tests:
TestCheckObjectFormats,TestValidateObjectFormat,TestListSourceRefsV2RejectsUnsupportedObjectFormatBeforeLsRefs,TestBuildV1UploadPackBodyDeclaresObjectFormat,TestRequestCapabilitiesEchoesObjectFormat,TestBuildUpdateRequestSHA256Target,TestBuildUpdateRequestSHA1TargetUnchanged,TestParseCommitParents_ObjectFormat,TestPackStreamObserverScansSHA256Pack.go test ./...,mise run test:git-http-backend,mise run test:git-http-backend:sha256andgolangci-lint runall pass.Merge Danger
Door: two-way
Blast Radius: wire requests
Every v2 request and every receive-pack now carries
object-formatwhenever the server advertises it, SHA-1 servers included. Real git does the same, so servers already accept it.A sync between repositories of different formats now fails before fetching, with a new error, instead of failing the push after a full fetch. It could never succeed, so no working setup changes.
ExtractCommitParentsandExtractCommitParentsWithCachetake a new format argument. Both are ininternal/, so no external callers break.CI does not run the git-http-backend tests, so the SHA-256 end-to-end coverage only runs locally.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FU3noQ5Lu6XeV7atoVDTmW
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->