Skip to content

feat: support cloning a single revision - #2824

Draft
Sebastian Thiel (Byron) wants to merge 1 commit into
mainfrom
fetch-revision
Draft

feat: support cloning a single revision#2824
Sebastian Thiel (Byron) wants to merge 1 commit into
mainfrom
fetch-revision

Conversation

@Byron

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-5.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #1930

Summary

  • add PrepareFetch::with_revision() for cloning HEAD, a full ref name, or a full object ID into a detached HEAD
  • add the plumbing --revision option while preserving the existing --ref behavior
  • avoid creating ordinary refs or persisting a fetch refspec for revision-only clones

The behavior follows Git commit 337855629f59 and its t/t5621-clone-revision.sh coverage.

Validation

  • cargo fmt --all -- --check
  • cargo test -p gix --features blocking-network-client,blocking-http-transport-curl clone
  • cargo test -p gitoxide clone_revision_is_distinct_from_ref
  • cargo check -p gix --no-default-features --features sha1,blocking-network-client,worktree-mutation
  • cargo check -p gix --no-default-features --features sha1,async-network-client-async-std,worktree-mutation
  • cargo doc -p gix --no-deps --features blocking-network-client,worktree-mutation

A full object ID passed through with_ref_name() produced an object-ID refspec mapping and panicked while clone assumed every mapping had a name. Branch and tag checkout also retained ordinary clone tracking semantics instead of offering a single-revision mode.

Add PrepareFetch::with_revision() and gix clone --revision for full refs, HEAD, and full object IDs. Revision clones use one source-only implicit refspec, detach HEAD to the fetched commit, create no ordinary refs, persist no fetch refspec, and disable tag following. Existing with_ref_name() and --ref behavior stays unchanged.

This follows Git commit 337855629f59 (builtin/clone: teach git-clone(1) the --revision= option) and its t/t5621-clone-revision.sh behavior.

Validation:
- cargo fmt --all -- --check
- cargo test -p gix --features blocking-network-client,blocking-http-transport-curl clone
- cargo test -p gitoxide clone_revision_is_distinct_from_ref
- cargo check -p gix --no-default-features --features sha1,blocking-network-client,worktree-mutation
- cargo check -p gix --no-default-features --features sha1,async-network-client-async-std,worktree-mutation
- cargo doc -p gix --no-deps --features blocking-network-client,worktree-mutation
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.

checkout of a specific branch, tag or revision does not work

2 participants