SHA-256 clone and fetch#2584
Conversation
The cargo check MSRV (ubuntu-latest) job failed while compiling gix with default features because gix/src/create.rs directly referenced gix_hash::Kind::Sha256. In the default SHA-1-only feature set, that enum variant is not compiled into gix-hash, producing E0599. Route object-format config generation through a feature-aware helper so SHA-1-only builds do not name the SHA-256 variant, while builds with sha256 enabled still write extensions.objectFormat = sha256 for SHA-256 repositories.
The test-journey job failed in the SHA-256 clone scenario because the test cloned into ../sha256-clone from inside a temporary sandbox. That resolves to a fixed path in the sandbox parent, so a previous run or shared temp parent can leave the destination non-empty and make clone initialization fail. Clone into sha256-clone inside the unique sandbox instead, then run the follow-up assertions from that directory.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05a87e5b2d
ℹ️ 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 (@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 (@codex) address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR extends gitoxide’s clone/fetch path to properly negotiate and persist SHA-256 repositories, including client-side protocol v2 object-format handling and repo initialization/configuration for non-SHA1 object formats.
Changes:
- Add SHA-256 repo initialization support by configuring
core.repositoryformatversionandextensions.objectformat. - Negotiate
object-formatas a global v2 capability and plumb the selected hash through fetch/clone/refmap. - Add journey + protocol tests and CI recipes to exercise SHA-256 clone behavior and sha1/sha256 feature combinations.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/tools/src/lib.rs | Serialize/robustify git-daemon port allocation for journey tests. |
| tests/journey/gix.sh | Add journey coverage for reading and cloning SHA-256 repositories. |
| tests/helpers.sh | Add helper to create a small SHA-256 git repository in a sandbox. |
| src/plumbing/main.rs | Plumb CLI object_hash into clone options. |
| justfile | Expand check/unit-tests to validate sha1/sha256 feature combinations for gix-protocol. |
| gix/src/create.rs | Add object_hash option to init logic; write extensions.objectformat for SHA-256 repos. |
| gix/Cargo.toml | Forward sha1/sha256 feature selection into gix-protocol. |
| gix-protocol/tests/protocol/fetch/v2.rs | Update expected v2 request bytes to include object-format=sha1. |
| gix-protocol/tests/protocol/fetch/ref_map.rs | Add sha256 test ensuring object-format=sha256 is parsed into RefMap. |
| gix-protocol/tests/protocol/command.rs | Add tests asserting object-format is emitted as a global v2 capability. |
| gix-protocol/src/lib.rs | Enforce selecting sha1 or sha256 via compile-time error. |
| gix-protocol/src/fetch/refmap/init.rs | Determine object hash from capabilities and use it consistently in refmap init. |
| gix-protocol/src/command.rs | Emit object-format as a global v2 feature and allow it during validation. |
| gitoxide-core/src/repository/clone.rs | Initialize cloned repositories using the requested object_hash. |
Review comments addressed: - `repositoryformatversion` was written as `0` for SHA-1 repositories. This now omits repository format configuration for the default hash and only writes version `1` plus `extensions.objectformat` for SHA-256. - V0/V1 fetch negotiation only advertised standard fetch capabilities. This now echoes the server-advertised `object-format` capability for fetch across V0, V1, and V2. - `object_format_feature()` allocated for known object formats. This now borrows the known `sha1` and `sha256` values and only allocates for unknown values. Tests cover SHA-1/SHA-256 init config, V0/V1 object-format negotiation, borrowed object-format values, and serialized V1 fetch requests.
3545829 to
8e423f4
Compare
Keep gix-protocol unit-test invocations on the existing SHA-1 fixtures by enabling sha1 alongside sha256, and gate the default-object-hash init assertion to sha1 builds.
The git-daemon readiness loop could wait forever while holding the port-allocation lock if the child stayed alive but never accepted connections. Bound each startup attempt to ten seconds and preserve the last connection error before trying another port. The new dirwalk plumbing command lacked journey coverage. Add journey tests for the default invocation, matching untracked mode, and statistics output.
Tasks