Skip to content

Commit 0f3a4b0

Browse files
committed
fix: gix attrs query now allows to match directories as signalled by the trailing slash
Patterns exist that end in a trailing slash and that will naturally match these now, and `git` can do the same.
1 parent ea0ea88 commit 0f3a4b0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

gitoxide-core/src/repository/attributes/query.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@ pub(crate) mod function {
8383
.adjust_for_bare(repo.is_bare()),
8484
)?;
8585
for pattern in pathspec.search().patterns() {
86-
let entry = cache.at_entry(pattern.path(), Some(false))?;
86+
let path = pattern.path();
87+
let entry = cache.at_entry(
88+
path,
89+
pattern
90+
.signature
91+
.contains(gix::pathspec::MagicSignature::MUST_BE_DIR)
92+
.into(),
93+
)?;
8794
if !entry.matching_attributes(&mut matches) {
8895
continue;
8996
}
90-
print_match(&matches, pattern.path(), &mut out)?;
97+
print_match(&matches, path, &mut out)?;
9198
}
9299
}
93100
}

gitoxide-core/src/repository/exclude.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,18 @@ pub fn query(
8888
.adjust_for_bare(repo.is_bare()),
8989
)?;
9090
for pattern in pathspec.search().patterns() {
91-
let entry = cache.at_entry(pattern.path(), None)?;
91+
let path = pattern.path();
92+
let entry = cache.at_entry(
93+
path,
94+
pattern
95+
.signature
96+
.contains(gix::pathspec::MagicSignature::MUST_BE_DIR)
97+
.into(),
98+
)?;
9299
let match_ = entry
93100
.matching_exclude_pattern()
94101
.and_then(|m| (show_ignore_patterns || !m.pattern.is_negative()).then_some(m));
95-
print_match(match_, pattern.path(), &mut out)?;
102+
print_match(match_, path, &mut out)?;
96103
}
97104
}
98105
}

0 commit comments

Comments
 (0)