Skip to content

Commit 5054780

Browse files
committed
feat: add Repository::checkout_options().
It's a low-level set of options to drive (quite unsafe) checkouts. They are unsafe as they may be configured to overwrite, and are in no way similar to `git checkout`.
1 parent f93aa61 commit 5054780

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

gix/src/clone/checkout.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ pub mod main_worktree {
118118
})?;
119119
let mut index = gix_index::File::from_state(index, repo.index_path());
120120

121-
let mut opts = repo
122-
.config
123-
.checkout_options(repo, gix_worktree::stack::state::attributes::Source::IdMapping)?;
121+
let mut opts = repo.checkout_options(gix_worktree::stack::state::attributes::Source::IdMapping)?;
124122
opts.destination_is_initially_empty = true;
125123

126124
let mut files = progress.add_child_with_id("checkout".to_string(), ProgressId::CheckoutFiles.into());

gix/src/repository/checkout.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use crate::{config, Repository};
2+
3+
impl Repository {
4+
/// Return options that can be used to drive a low-level checkout operation.
5+
/// Use `attributes_source` to determine where `.gitattributes` files should be read from, which depends on
6+
/// the presence of a worktree to begin with.
7+
/// Here, typically this value would be [`gix_worktree::stack::state::attributes::Source::IdMapping`]
8+
pub fn checkout_options(
9+
&self,
10+
attributes_source: gix_worktree::stack::state::attributes::Source,
11+
) -> Result<gix_worktree_state::checkout::Options, config::checkout_options::Error> {
12+
self.config.checkout_options(self, attributes_source)
13+
}
14+
}

gix/src/repository/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ pub enum Kind {
2020
#[cfg(any(feature = "attributes", feature = "excludes"))]
2121
pub mod attributes;
2222
mod cache;
23+
#[cfg(feature = "worktree-mutation")]
24+
mod checkout;
2325
mod config;
26+
2427
///
2528
#[cfg(feature = "blob-diff")]
2629
mod diff;

0 commit comments

Comments
 (0)