Skip to content

Commit 9bf01e4

Browse files
committed
feat: gix clone with --ref support.
`--ref` is similar to `--branch`, but was renamed as it also supports tags for example.
1 parent acbfa6f commit 9bf01e4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Diff for: gitoxide-core/src/repository/clone.rs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct Options {
66
pub handshake_info: bool,
77
pub no_tags: bool,
88
pub shallow: gix::remote::fetch::Shallow,
9+
pub ref_name: Option<gix::refs::PartialName>,
910
}
1011

1112
pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=3;
@@ -31,6 +32,7 @@ pub(crate) mod function {
3132
handshake_info,
3233
bare,
3334
no_tags,
35+
ref_name,
3436
shallow,
3537
}: Options,
3638
) -> anyhow::Result<()>
@@ -75,6 +77,7 @@ pub(crate) mod function {
7577
}
7678
let (mut checkout, fetch_outcome) = prepare
7779
.with_shallow(shallow)
80+
.with_ref_name(ref_name.as_ref())?
7881
.fetch_then_checkout(&mut progress, &gix::interrupt::IS_INTERRUPTED)?;
7982

8083
let (repo, outcome) = if bare {

Diff for: src/plumbing/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ pub fn main() -> Result<()> {
404404
handshake_info,
405405
bare,
406406
no_tags,
407+
ref_name,
407408
remote,
408409
shallow,
409410
directory,
@@ -413,6 +414,7 @@ pub fn main() -> Result<()> {
413414
bare,
414415
handshake_info,
415416
no_tags,
417+
ref_name,
416418
shallow: shallow.into(),
417419
};
418420
prepare_and_run(

Diff for: src/plumbing/options/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ pub mod clone {
434434
/// The url of the remote to connect to, like `https://github.com/byron/gitoxide`.
435435
pub remote: OsString,
436436

437+
/// The name of the reference to check out.
438+
#[clap(long = "ref", value_parser = crate::shared::AsPartialRefName, value_name = "REF_NAME")]
439+
pub ref_name: Option<gix::refs::PartialName>,
440+
437441
/// The directory to initialize with the new repository and to which all data should be written.
438442
pub directory: Option<PathBuf>,
439443
}

0 commit comments

Comments
 (0)