Skip to content

Commit f066f98

Browse files
committed
feat: PathSpec implements gix_status::PathSpec to allow it to be used there.
The reason we need a trait and can't do with simply a function is that multiple calls are needed to test for inclusion *and* allow the common-prefix optimization.
1 parent 2d01125 commit f066f98

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ default = ["max-performance-safe", "comfort", "basic", "extras"]
5151
basic = ["blob-diff", "revision", "index"]
5252

5353
## Various additional features and capabilities that are not necessarily part of what most users would need.
54-
extras = ["worktree-stream", "worktree-archive", "revparse-regex", "mailmap", "excludes", "attributes", "worktree-mutation", "credentials", "interrupt"]
54+
extras = ["worktree-stream", "worktree-archive", "revparse-regex", "mailmap", "excludes", "attributes", "worktree-mutation", "credentials", "interrupt", "status"]
5555

5656
## Various progress-related features that improve the look of progress message units.
5757
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
@@ -61,6 +61,9 @@ comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human
6161
#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.
6262
#! Providers of libraries should only activate the components they need.
6363

64+
## Obtain information similar to `git status`.
65+
status = ["gix-status"]
66+
6467
## Utilities for interrupting computations and cleaning up tempfiles.
6568
interrupt = ["dep:signal-hook", "gix-tempfile/signals"]
6669

@@ -239,6 +242,7 @@ gix-hashtable = { version = "^0.4.0", path = "../gix-hashtable" }
239242
gix-commitgraph = { version = "^0.20.0", path = "../gix-commitgraph" }
240243
gix-pathspec = { version = "^0.2.0", path = "../gix-pathspec", optional = true }
241244
gix-submodule = { version = "^0.3.0", path = "../gix-submodule", optional = true }
245+
gix-status = { version = "^0.1.0", path = "../gix-status", optional = true }
242246

243247
gix-worktree-stream = { version = "^0.4.0", path = "../gix-worktree-stream", optional = true }
244248
gix-archive = { version = "^0.4.0", path = "../gix-archive", default-features = false, optional = true }

gix/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ pub use gix_ref as refs;
124124
pub use gix_refspec as refspec;
125125
pub use gix_revwalk as revwalk;
126126
pub use gix_sec as sec;
127+
#[cfg(feature = "status")]
128+
pub use gix_status as status;
127129
pub use gix_tempfile as tempfile;
128130
pub use gix_trace as trace;
129131
pub use gix_traverse as traverse;

gix/src/pathspec.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,14 @@ impl<'repo> Pathspec<'repo> {
144144
})
145145
}
146146
}
147+
148+
#[cfg(feature = "status")]
149+
impl gix_status::Pathspec for Pathspec<'_> {
150+
fn common_prefix(&self) -> &BStr {
151+
self.search.common_prefix()
152+
}
153+
154+
fn is_included(&mut self, relative_path: &BStr, is_dir: Option<bool>) -> bool {
155+
self.is_included(relative_path, is_dir)
156+
}
157+
}

0 commit comments

Comments
 (0)