Skip to content

Commit 3438bc9

Browse files
committed
adapt to changes in gix-dir
1 parent b0aa390 commit 3438bc9

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

gitoxide-core/src/repository/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) mod function {
5555
bail!("Need a worktree to clean, this is a bare repository");
5656
};
5757

58-
let index = repo.index()?;
58+
let index = repo.index_or_empty()?;
5959
let has_patterns = !patterns.is_empty();
6060
let mut collect = InterruptableCollect::default();
6161
let collapse_directories = CollapseDirectory;

gix/src/repository/dirwalk.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::bstr::BStr;
22
use crate::{config, dirwalk, Repository};
3-
use std::path::Path;
3+
use std::path::PathBuf;
44

55
/// The error returned by [dirwalk()](Repository::dirwalk()).
66
#[derive(Debug, thiserror::Error)]
@@ -42,7 +42,8 @@ impl Repository {
4242
patterns: impl IntoIterator<Item = impl AsRef<BStr>>,
4343
options: dirwalk::Options,
4444
delegate: &mut dyn gix_dir::walk::Delegate,
45-
) -> Result<gix_dir::walk::Outcome, Error> {
45+
) -> Result<(gix_dir::walk::Outcome, PathBuf), Error> {
46+
let _span = gix_trace::coarse!("gix::dirwalk");
4647
let workdir = self.work_dir().ok_or(Error::MissinWorkDir)?;
4748
let mut excludes = self
4849
.excludes(
@@ -59,14 +60,13 @@ impl Repository {
5960
crate::worktree::stack::state::attributes::Source::WorktreeThenIdMapping,
6061
)?
6162
.into_parts();
63+
gix_trace::debug!(patterns = ?pathspec.patterns().map(|p| p.path()).collect::<Vec<_>>());
6264

63-
let prefix = self.prefix()?.unwrap_or(Path::new(""));
6465
let git_dir_realpath =
6566
crate::path::realpath_opts(self.git_dir(), self.current_dir(), crate::path::realpath::MAX_SYMLINKS)?;
6667
let fs_caps = self.filesystem_options()?;
6768
let accelerate_lookup = fs_caps.ignore_case.then(|| index.prepare_icase_backing());
6869
gix_dir::walk(
69-
&workdir.join(prefix),
7070
workdir,
7171
gix_dir::walk::Context {
7272
git_dir_realpath: git_dir_realpath.as_ref(),
@@ -85,6 +85,7 @@ impl Repository {
8585
},
8686
excludes: Some(&mut excludes),
8787
objects: &self.objects,
88+
explicit_traversal_root: None,
8889
},
8990
options.into(),
9091
delegate,

gix/src/repository/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Repository {
5252
let cache = self.attributes_only(&index, gix_worktree::stack::state::attributes::Source::IdMapping)?;
5353
(cache, IndexPersistedOrInMemory::InMemory(index))
5454
} else {
55-
let index = self.index()?;
55+
let index = self.index_or_empty()?;
5656
let cache = self.attributes_only(
5757
&index,
5858
gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping,
Binary file not shown.

gix/tests/fixtures/make_basic_repo.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ git init non-bare-repo-without-index
2525
git add this && git commit -m "init"
2626
rm .git/index
2727
)
28+
29+
git init all-untracked
30+
(cd all-untracked
31+
>a
32+
mkdir d
33+
>d/a
34+
)

gix/tests/repository/filter.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
use std::path::Path;
22

3+
#[test]
4+
fn pipeline_in_nonbare_repo_without_index() -> crate::Result {
5+
let repo = named_subrepo_opts("make_basic_repo.sh", "all-untracked", Default::default())?;
6+
let _ = repo.filter_pipeline(None).expect("does not fail due to missing index");
7+
Ok(())
8+
}
9+
310
use gix::bstr::ByteSlice;
411
use gix_filter::driver::apply::Delay;
512

6-
use crate::util::named_repo;
13+
use crate::util::{named_repo, named_subrepo_opts};
714

815
#[test]
916
fn pipeline_in_repo_without_special_options() -> crate::Result {

gix/tests/repository/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mod dirwalk {
3434
.map(|e| (e.0.rela_path.to_string(), e.0.disk_kind.expect("kind is known")))
3535
.collect::<Vec<_>>(),
3636
[
37+
("all-untracked".to_string(), Repository),
3738
("bare-repo-with-index.git".to_string(), Directory),
3839
("bare.git".into(), Directory),
3940
("non-bare-repo-without-index".into(), Repository),

0 commit comments

Comments
 (0)