Skip to content

Commit 4e0feff

Browse files
committed
feat: add index-to-worktree status with rename tracking
1 parent df81577 commit 4e0feff

File tree

17 files changed

+1302
-14
lines changed

17 files changed

+1302
-14
lines changed

Cargo.lock

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

gix-diff/tests/rewrites/tracker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn copy_by_id() -> crate::Result {
151151
let id = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e");
152152
let source_a = Source {
153153
entry_mode: EntryKind::Blob.into(),
154-
id: id,
154+
id,
155155
kind: SourceKind::Copy,
156156
location: "a".into(),
157157
change: &Change {
@@ -303,7 +303,7 @@ fn copy_by_50_percent_similarity() -> crate::Result {
303303
let id = hex_to_id("78981922613b2afb6025042ff6bd878ac1994e85");
304304
let source_a = Source {
305305
entry_mode: EntryKind::Blob.into(),
306-
id: id,
306+
id,
307307
kind: SourceKind::Copy,
308308
location: "a".into(),
309309
change: &Change {
@@ -480,7 +480,7 @@ fn rename_by_50_percent_similarity() -> crate::Result {
480480
src.unwrap(),
481481
Source {
482482
entry_mode: EntryKind::Blob.into(),
483-
id: id,
483+
id,
484484
kind: SourceKind::Rename,
485485
location: "a".into(),
486486
change: &Change {

gix-status/Cargo.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,29 @@ autotests = false
1313
[lib]
1414
doctest = false
1515

16+
[features]
17+
## Add support for tracking rewrites along with checking for worktree modifications.
18+
worktree-rewrites = ["dep:gix-dir", "dep:gix-diff"]
19+
1620
[dependencies]
1721
gix-index = { version = "^0.30.0", path = "../gix-index" }
1822
gix-fs = { version = "^0.10.0", path = "../gix-fs" }
1923
gix-hash = { version = "^0.14.1", path = "../gix-hash" }
2024
gix-object = { version = "^0.41.1", path = "../gix-object" }
2125
gix-path = { version = "^0.10.6", path = "../gix-path" }
22-
gix-features = { version = "^0.38.0", path = "../gix-features" }
26+
gix-features = { version = "^0.38.0", path = "../gix-features", features = ["progress"] }
2327
gix-filter = { version = "^0.10.0", path = "../gix-filter" }
2428
gix-worktree = { version = "^0.31.0", path = "../gix-worktree", default-features = false, features = ["attributes"] }
2529
gix-pathspec = { version = "^0.7.0", path = "../gix-pathspec" }
2630

31+
gix-dir = { version = "^0.1.0", path = "../gix-dir", optional = true }
32+
gix-diff = { version = "^0.41.0", path = "../gix-diff", default-features = false, features = ["blob"], optional = true }
33+
2734
thiserror = "1.0.26"
2835
filetime = "0.2.15"
2936
bstr = { version = "1.3.0", default-features = false }
37+
38+
document-features = { version = "0.2.0", optional = true }
39+
40+
[package.metadata.docs.rs]
41+
features = ["document-features", "worktree-rewrites"]

gix-status/src/index_as_worktree/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ pub use types::{Change, Conflict, Context, EntryStatus, Error, Options, Outcome,
66
mod recorder;
77
pub use recorder::{Record, Recorder};
88

9-
pub(crate) mod function;
9+
pub(super) mod function;
1010
///
1111
pub mod traits;

gix-status/src/index_as_worktree/recorder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::index_as_worktree::{EntryStatus, VisitEntry};
66
/// A record of a change.
77
///
88
/// It's created either if there is a conflict or a change, or both.
9-
#[derive(Debug)]
9+
#[derive(Debug, Clone)]
1010
pub struct Record<'index, T, U> {
1111
/// The index entry that is changed.
1212
pub entry: &'index index::Entry,

gix-status/src/index_as_worktree/types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum Error {
2121
}
2222

2323
/// Options that control how the index status with a worktree is computed.
24-
#[derive(Clone, Default)]
24+
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
2525
pub struct Options {
2626
/// Capabilities of the file system which affect the status computation.
2727
pub fs: gix_fs::Capabilities,
@@ -37,6 +37,9 @@ pub struct Options {
3737
#[derive(Clone)]
3838
pub struct Context<'a> {
3939
/// The pathspec to limit the amount of paths that are checked. Can be empty to allow all paths.
40+
///
41+
/// Note that these are expected to have a [commont_prefix()](gix_pathspec::Search::common_prefix()) according
42+
/// to the prefix of the repository to efficiently limit the scope of the paths we process.
4043
pub pathspec: gix_pathspec::Search,
4144
/// A stack pre-configured to allow accessing attributes for each entry, as required for `filter`
4245
/// and possibly pathspecs.

0 commit comments

Comments
 (0)