Skip to content

Commit 518fbbc

Browse files
committed
feat: add Repository::workdir() as replacement for Repository::work_dir().
Keep the latter as deprecated though.
1 parent 28080ae commit 518fbbc

File tree

33 files changed

+79
-73
lines changed

33 files changed

+79
-73
lines changed

gix/examples/clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ fn main() -> anyhow::Result<()> {
2727

2828
println!(
2929
"Checking out into {:?} ...",
30-
prepare_checkout.repo().work_dir().expect("should be there")
30+
prepare_checkout.repo().workdir().expect("should be there")
3131
);
3232

3333
let (repo, _) = prepare_checkout.main_worktree(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)?;
34-
println!("Repo cloned into {:?}", repo.work_dir().expect("directory pre-created"));
34+
println!("Repo cloned into {:?}", repo.workdir().expect("directory pre-created"));
3535

3636
let remote = repo
3737
.find_default_remote(gix::remote::Direction::Fetch)

gix/examples/stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gix::{prelude::ObjectIdExt, Reference};
44

55
fn main() -> Result<(), Box<dyn std::error::Error>> {
66
let mut repo = gix::discover(".")?;
7-
println!("Repo: {}", repo.work_dir().unwrap_or_else(|| repo.git_dir()).display());
7+
println!("Repo: {}", repo.workdir().unwrap_or_else(|| repo.git_dir()).display());
88
let mut max_parents = 0;
99
let mut avg_parents = 0;
1010
repo.object_cache_size(32 * 1024);

gix/src/clone/access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl PrepareFetch {
6868
impl Drop for PrepareFetch {
6969
fn drop(&mut self) {
7070
if let Some(repo) = self.repo.take() {
71-
std::fs::remove_dir_all(repo.work_dir().unwrap_or_else(|| repo.path())).ok();
71+
std::fs::remove_dir_all(repo.workdir().unwrap_or_else(|| repo.path())).ok();
7272
}
7373
}
7474
}

gix/src/clone/checkout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub mod main_worktree {
9292
.repo
9393
.as_ref()
9494
.expect("BUG: this method may only be called until it is successful");
95-
let workdir = repo.work_dir().ok_or_else(|| Error::BareRepository {
95+
let workdir = repo.workdir().ok_or_else(|| Error::BareRepository {
9696
git_dir: repo.git_dir().to_owned(),
9797
})?;
9898

@@ -173,7 +173,7 @@ impl PrepareCheckout {
173173
impl Drop for PrepareCheckout {
174174
fn drop(&mut self) {
175175
if let Some(repo) = self.repo.take() {
176-
std::fs::remove_dir_all(repo.work_dir().unwrap_or_else(|| repo.path())).ok();
176+
std::fs::remove_dir_all(repo.workdir().unwrap_or_else(|| repo.path())).ok();
177177
}
178178
}
179179
}

gix/src/config/cache/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl crate::Repository {
303303
}
304304

305305
fn apply_changed_values(&mut self) {
306-
self.refs.write_reflog = util::reflog_or_default(self.config.reflog, self.work_dir().is_some());
306+
self.refs.write_reflog = util::reflog_or_default(self.config.reflog, self.workdir().is_some());
307307
self.refs.namespace.clone_from(&self.config.refs_namespace);
308308
}
309309
}

gix/src/dirwalk/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Outcome {
3434
/// The pathspecs used to guide the operation,
3535
pub pathspec: PathspecDetached,
3636
/// The root actually being used for the traversal, and useful to transform the paths returned for the user.
37-
/// It's always within the [`work-dir`](Repository::work_dir).
37+
/// It's always within the [`work-dir`](Repository::workdir).
3838
pub traversal_root: PathBuf,
3939
/// The actual result of the dirwalk.
4040
pub dirwalk: gix_dir::walk::Outcome,

gix/src/dirwalk/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct Outcome<'repo> {
6464
/// The pathspecs used to guide the operation,
6565
pub pathspec: Pathspec<'repo>,
6666
/// The root actually being used for the traversal, and useful to transform the paths returned for the user.
67-
/// It's always within the [`work-dir`](crate::Repository::work_dir).
67+
/// It's always within the [`work-dir`](crate::Repository::workdir).
6868
pub traversal_root: PathBuf,
6969
/// The actual result of the dirwalk.
7070
pub dirwalk: gix_dir::walk::Outcome,

gix/src/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl Pipeline<'_> {
228228

229229
let rela_path_as_path = gix_path::from_bstr(rela_path);
230230
let repo = self.repo;
231-
let worktree_dir = repo.work_dir().ok_or(Error::MissingWorktree)?;
231+
let worktree_dir = repo.workdir().ok_or(Error::MissingWorktree)?;
232232
let path = worktree_dir.join(&rela_path_as_path);
233233
let md = match std::fs::symlink_metadata(&path) {
234234
Ok(md) => md,

gix/src/pathspec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'repo> Pathspec<'repo> {
6060
patterns,
6161
prefix,
6262
&gix_path::realpath_opts(
63-
repo.work_dir().unwrap_or_else(|| repo.git_dir()),
63+
repo.workdir().unwrap_or_else(|| repo.git_dir()),
6464
repo.options.current_dir_or_empty(),
6565
gix_path::realpath::MAX_SYMLINKS,
6666
)?,

gix/src/remote/connection/fetch/update_refs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ fn insert_head(
444444
head: Option<crate::Head<'_>>,
445445
out: &mut BTreeMap<gix_ref::FullName, Vec<PathBuf>>,
446446
) -> Result<(), update::Error> {
447-
if let Some((head, wd)) = head.and_then(|head| head.repo.work_dir().map(|wd| (head, wd))) {
447+
if let Some((head, wd)) = head.and_then(|head| head.repo.workdir().map(|wd| (head, wd))) {
448448
out.entry("HEAD".try_into().expect("valid"))
449449
.or_default()
450450
.push(wd.to_owned());

0 commit comments

Comments
 (0)