Skip to content

Commit 98da8ba

Browse files
committed
Merge branch 'worktree-stack'
2 parents f06f666 + 3a41d5c commit 98da8ba

File tree

113 files changed

+4083
-1918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+4083
-1918
lines changed

Cargo.lock

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ members = [
161161
"git-lock",
162162
"git-attributes",
163163
"git-pathspec",
164+
"git-path",
164165
"git-repository",
165166
"gitoxide-core",
166167
"git-tui",

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili
4848
* **mailmap**
4949
* [x] **verify** - check entries of a mailmap file for parse errors and display them
5050
* **repository**
51+
* **exclude**
52+
* [x] **query** - check if path specs are excluded via gits exclusion rules like `.gitignore`.
5153
* **verify** - validate a whole repository, for now only the object database.
5254
* **commit**
5355
* [x] **describe** - identify a commit by its closest tag in its past
@@ -122,6 +124,7 @@ Crates that seem feature complete and need to see some more use before they can
122124
* [git-bitmap](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-bitmap)
123125
* [git-revision](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-revision)
124126
* [git-attributes](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-attributes)
127+
* [git-path](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-path)
125128
* **idea**
126129
* [git-note](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-note)
127130
* [git-filter](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-filter)

crate-status.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ Check out the [performance discussion][git-traverse-performance] as well.
221221
* [x] parsing
222222
* [x] lookup and mapping of author names
223223

224+
### git-path
225+
* [x] transformations to and from bytes
226+
* [x] conversions between different platforms
227+
* **spec**
228+
* [ ] parse
229+
* [ ] check for match
230+
224231
### git-pathspec
225232
* [ ] parse
226233
* [ ] check for match
@@ -429,7 +436,8 @@ See its [README.md](https://github.com/Byron/gitoxide/blob/main/git-lock/README.
429436
* **refs**
430437
* [ ] run transaction hooks and handle special repository states like quarantine
431438
* [ ] support for different backends like `files` and `reftable`
432-
* [ ] worktrees
439+
* **worktrees**
440+
* [ ] open a repository with worktrees
433441
* [ ] remotes with push and pull
434442
* [x] mailmap
435443
* [x] object replacements (`git replace`)

etc/check-package-size.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ echo "in root: gitoxide CLI"
1919
(enter cargo-smart-release && indent cargo diet -n --package-size-limit 90KB)
2020
(enter git-actor && indent cargo diet -n --package-size-limit 5KB)
2121
(enter git-pathspec && indent cargo diet -n --package-size-limit 5KB)
22+
(enter git-path && indent cargo diet -n --package-size-limit 10KB)
2223
(enter git-attributes && indent cargo diet -n --package-size-limit 10KB)
2324
(enter git-index && indent cargo diet -n --package-size-limit 30KB)
2425
(enter git-worktree && indent cargo diet -n --package-size-limit 25KB)
@@ -51,6 +52,6 @@ echo "in root: gitoxide CLI"
5152
(enter git-odb && indent cargo diet -n --package-size-limit 120KB)
5253
(enter git-protocol && indent cargo diet -n --package-size-limit 50KB)
5354
(enter git-packetline && indent cargo diet -n --package-size-limit 35KB)
54-
(enter git-repository && indent cargo diet -n --package-size-limit 90KB)
55+
(enter git-repository && indent cargo diet -n --package-size-limit 100KB)
5556
(enter git-transport && indent cargo diet -n --package-size-limit 50KB)
5657
(enter gitoxide-core && indent cargo diet -n --package-size-limit 70KB)

git-attributes/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ doctest = false
1313

1414
[features]
1515
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
16-
serde1 = ["serde", "bstr/serde1", "git-glob/serde1"]
16+
serde1 = ["serde", "bstr/serde1", "git-glob/serde1", "compact_str/serde"]
1717

1818
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1919

2020
[dependencies]
2121
git-features = { version = "^0.20.0", path = "../git-features" }
22+
git-path = { version = "^0.1.0", path = "../git-path" }
2223
git-quote = { version = "^0.2.0", path = "../git-quote" }
2324
git-glob = { version = "^0.2.0", path = "../git-glob" }
2425

2526
bstr = { version = "0.2.13", default-features = false, features = ["std"]}
2627
unicode-bom = "1.1.4"
2728
quick-error = "2.0.0"
2829
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
30+
compact_str = "0.3.2"
2931

3032
[dev-dependencies]
3133
git-testtools = { path = "../tests/tools"}

git-attributes/src/lib.rs

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
#![deny(rust_2018_idioms)]
33

44
use bstr::{BStr, BString};
5+
use compact_str::CompactStr;
6+
use std::path::PathBuf;
57

8+
pub use git_glob as glob;
9+
10+
/// The state an attribute can be in, referencing the value.
11+
///
12+
/// Note that this doesn't contain the name.
613
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
714
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
8-
pub enum State<'a> {
15+
pub enum StateRef<'a> {
916
/// The attribute is listed, or has the special value 'true'
1017
Set,
1118
/// The attribute has the special value 'false', or was prefixed with a `-` sign.
@@ -18,87 +25,75 @@ pub enum State<'a> {
1825
Unspecified,
1926
}
2027

21-
/// A grouping of lists of patterns while possibly keeping associated to their base path.
28+
/// The state an attribute can be in, owning the value.
2229
///
23-
/// Patterns with base path are queryable relative to that base, otherwise they are relative to the repository root.
30+
/// Note that this doesn't contain the name.
31+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
32+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
33+
pub enum State {
34+
/// The attribute is listed, or has the special value 'true'
35+
Set,
36+
/// The attribute has the special value 'false', or was prefixed with a `-` sign.
37+
Unset,
38+
/// The attribute is set to the given value, which followed the `=` sign.
39+
/// Note that values can be empty.
40+
Value(compact_str::CompactStr),
41+
/// The attribute isn't mentioned with a given path or is explicitly set to `Unspecified` using the `!` sign.
42+
Unspecified,
43+
}
44+
45+
/// Name an attribute and describe it's assigned state.
2446
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
25-
pub struct MatchGroup<T: match_group::Tag> {
47+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
48+
pub struct Assignment {
49+
/// The name of the attribute.
50+
pub name: CompactStr,
51+
/// The state of the attribute.
52+
pub state: State,
53+
}
54+
55+
/// A grouping of lists of patterns while possibly keeping associated to their base path.
56+
///
57+
/// Pattern lists with base path are queryable relative to that base, otherwise they are relative to the repository root.
58+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Default)]
59+
pub struct MatchGroup<T: match_group::Pattern = Attributes> {
2660
/// A list of pattern lists, each representing a patterns from a file or specified by hand, in the order they were
2761
/// specified in.
2862
///
2963
/// During matching, this order is reversed.
3064
pub patterns: Vec<PatternList<T>>,
3165
}
3266

33-
/// A list of patterns with an optional names, for matching against it.
34-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
35-
pub struct PatternList<T: match_group::Tag> {
36-
/// Patterns and their associated data in the order they were loaded in or specified.
67+
/// A list of patterns which optionally know where they were loaded from and what their base is.
68+
///
69+
/// Knowing their base which is relative to a source directory, it will ignore all path to match against
70+
/// that don't also start with said base.
71+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Default)]
72+
pub struct PatternList<T: match_group::Pattern> {
73+
/// Patterns and their associated data in the order they were loaded in or specified,
74+
/// the line number in its source file or its sequence number (_`(pattern, value, line_number)`_).
3775
///
3876
/// During matching, this order is reversed.
39-
pub patterns: Vec<(git_glob::Pattern, T::Value)>,
77+
pub patterns: Vec<PatternMapping<T::Value>>,
4078

41-
/// The path at which the patterns are located in a format suitable for matches, or `None` if the patterns
42-
/// are relative to the worktree root.
43-
base: Option<BString>,
44-
}
45-
46-
mod match_group {
47-
use crate::{MatchGroup, PatternList};
48-
use std::ffi::OsString;
49-
use std::path::PathBuf;
50-
51-
/// A marker trait to identify the type of a description.
52-
pub trait Tag: Clone + PartialEq + Eq + std::fmt::Debug + std::hash::Hash + Ord + PartialOrd {
53-
/// The value associated with a pattern.
54-
type Value: PartialEq + Eq + std::fmt::Debug + std::hash::Hash + Ord + PartialOrd + Clone;
55-
}
56-
57-
/// Identify ignore patterns.
58-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
59-
pub struct Ignore;
60-
impl Tag for Ignore {
61-
type Value = ();
62-
}
79+
/// The path from which the patterns were read, or `None` if the patterns
80+
/// don't originate in a file on disk.
81+
pub source: Option<PathBuf>,
6382

64-
/// Identify patterns with attributes.
65-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
66-
pub struct Attributes;
67-
impl Tag for Attributes {
68-
/// TODO: identify the actual value, should be name/State pairs, but there is the question of storage.
69-
type Value = ();
70-
}
71-
72-
impl MatchGroup<Ignore> {
73-
/// See [PatternList::<Ignore>::from_overrides()] for details.
74-
pub fn from_overrides(patterns: impl IntoIterator<Item = impl Into<OsString>>) -> Self {
75-
MatchGroup {
76-
patterns: vec![PatternList::<Ignore>::from_overrides(patterns)],
77-
}
78-
}
79-
}
83+
/// The parent directory of source, or `None` if the patterns are _global_ to match against the repository root.
84+
/// It's processed to contain slashes only and to end with a trailing slash, and is relative to the repository root.
85+
pub base: Option<BString>,
86+
}
8087

81-
impl PatternList<Ignore> {
82-
/// Parse a list of patterns, using slashes as path separators
83-
pub fn from_overrides(patterns: impl IntoIterator<Item = impl Into<OsString>>) -> Self {
84-
PatternList {
85-
patterns: patterns
86-
.into_iter()
87-
.map(Into::into)
88-
.filter_map(|pattern| {
89-
let pattern = git_features::path::into_bytes(PathBuf::from(pattern)).ok()?;
90-
git_glob::parse(pattern.as_ref()).map(|p| (p, ()))
91-
})
92-
.collect(),
93-
base: None,
94-
}
95-
}
96-
}
88+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
89+
pub struct PatternMapping<T> {
90+
pub pattern: git_glob::Pattern,
91+
pub value: T,
92+
pub sequence_number: usize,
9793
}
98-
pub use match_group::{Attributes, Ignore, Tag};
9994

100-
pub type Files = MatchGroup<Attributes>;
101-
pub type IgnoreFiles = MatchGroup<Ignore>;
95+
mod match_group;
96+
pub use match_group::{Attributes, Ignore, Match, Pattern};
10297

10398
pub mod parse;
10499

0 commit comments

Comments
 (0)