Skip to content

worktree stack supports excludes #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 121 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
568f013
change!: `Pattern::matches()` is now private (#301)
Byron Apr 21, 2022
0effef0
adapt to changes in git-glob (#301)
Byron Apr 21, 2022
cc1312d
Basic match group pattern matching (#301)
Byron Apr 21, 2022
afbb295
Baseline tests for global excludes and instantiation of pattern lists…
Byron Apr 21, 2022
0852f13
refactor (#301)
Byron Apr 21, 2022
4c9a51e
enforce nicer/unified names so use struct instead of tuple (#301)
Byron Apr 21, 2022
4a1e797
first succeding tests for global repository excludes (#301)
Byron Apr 22, 2022
ac53780
thanks clippy
Byron Apr 22, 2022
99c7b5f
more pendantic baseline parsing (#301)
Byron Apr 22, 2022
457c921
support for loading per-directory pattern lists as well (#301)
Byron Apr 22, 2022
f66c27e
generalize parsing of paths in pattern lists (#301)
Byron Apr 22, 2022
5992883
thanks clippy
Byron Apr 22, 2022
50b8c64
try using compatct_str for attribute storage (#301)
Byron Apr 22, 2022
f1635c3
feat: publicly accessible `Result` type (#301)
Byron Apr 23, 2022
fe9fb4c
refactor (#301)
Byron Apr 23, 2022
f8dd5ce
discover an entirely new class of exclude matches… (#301)
Byron Apr 23, 2022
cd58a1c
adapt to changes in git-glob and add failing test (#301)
Byron Apr 23, 2022
fb65a39
adjust baseline to only handle patterns that work without a dir stack…
Byron Apr 23, 2022
4f6cefc
Allow basename matches to work like before (#301)
Byron Apr 23, 2022
1ab4705
cleanup (#301)
Byron Apr 23, 2022
04ab5d3
also skip negative attribute patterns (#301)
Byron Apr 23, 2022
d80b321
Sketch how attribute states can be used (#301)
Byron Apr 23, 2022
97ee03d
sketch how attribute globals could be used in worktrees (#301)
Byron Apr 23, 2022
eb525f7
Sketch state for handling excludes (#301)
Byron Apr 24, 2022
f7c1920
fix release build
Byron Apr 21, 2022
d87d62d
Sketch state for handling attributes as well (#301)
Byron Apr 24, 2022
4b72045
re-export `git-glob` as its `Case` type is part of the public API (#301)
Byron Apr 24, 2022
ce40add
Add baseline test to motivate implementing ignore file stack (#301)
Byron Apr 24, 2022
2c88b57
feat: add `Default` impl for `pattern::Case` (#301)
Byron Apr 24, 2022
8d1000b
refactor to make push/pop with mutable state work; prepare to read .g…
Byron Apr 24, 2022
0424136
First primitive ignore pattern test works (#301)
Byron Apr 24, 2022
8674c11
Merge branch 'main' into worktree-stack
Byron Apr 25, 2022
e58b771
A baseline test that indicates how excludes aren't using data from th…
Byron Apr 25, 2022
5d619e6
add option to not follow symlinks when reading attribute files (#301)
Byron Apr 25, 2022
dec9f33
A test to check skip-worktree special case with ignore files (#301)
Byron Apr 25, 2022
155bb82
Make .gitignore name overridable (#301)
Byron Apr 25, 2022
475aa6a
refactor (#301)
Byron Apr 25, 2022
b199367
thanks clippy
Byron Apr 25, 2022
9841efb
An attempt to build a lookup table of attribute files, but… (#301)
Byron Apr 25, 2022
6f74f85
doing things directly works fortunately (#301)
Byron Apr 25, 2022
b14904b
refactor (#301)
Byron Apr 25, 2022
4234b84
try to keep borrows to path backing alive but… (#301)
Byron Apr 25, 2022
514e2f4
Fix borrow check issues the fast way, but… (#301)
Byron Apr 25, 2022
645ed50
feat: support for separating lifetimes of entries and path-backing (…
Byron Apr 25, 2022
e525b5e
Use a separate path mapping to enable clone-avoidance (#301)
Byron Apr 25, 2022
e4044a4
Support for shared attribute file names (#301)
Byron Apr 25, 2022
63f0839
fix MSRV (#301)
Byron Apr 25, 2022
883d78d
refactor (#301)
Byron Apr 26, 2022
34d0d5c
wire everything up to have all data where it needs to be, but… (#301)
Byron Apr 26, 2022
910d500
And finally, we can read ignore files from the index, too (#301)
Byron Apr 26, 2022
aeebc5f
thanks clippy
Byron Apr 26, 2022
2659816
customize stack operation to support the notion of directories (#301)
Byron Apr 27, 2022
8345b7c
refactor (#301)
Byron Apr 27, 2022
d078d6e
feat!: mild refactor of paths module to waste less on unix (#301)
Byron Apr 27, 2022
c55cac6
adjustments to go along with changes in git-features (#301)
Byron Apr 27, 2022
8d13f81
add empty git-path crate (#301)
Byron Apr 27, 2022
725e198
Copy all existing functions from git-features::path to git-path:: (#301)
Byron Apr 27, 2022
90611ce
change!: remove `path` module in favor of `git-path` crate (#301)
Byron Apr 27, 2022
47e607d
Use `git-path` crate instead of `git_features::path` (#301)
Byron Apr 27, 2022
9380e99
Use bstr intead of [u8] (#301)
Byron Apr 27, 2022
f158648
adapt to all changes in git-path with bstr support (#301)
Byron Apr 27, 2022
fdec111
thanks clippy
Byron Apr 27, 2022
5480159
refactor!: various name changes for more convenient API (#301)
Byron Apr 27, 2022
cc2d810
adapt to changes in git-path (#301)
Byron Apr 27, 2022
e868acc
The first indication that directory-based excludes work (#301)
Byron Apr 27, 2022
a6532e7
Don't hardcode case in state::Ignore (#301)
Byron Apr 27, 2022
21d4076
refactor (#301)
Byron Apr 27, 2022
e191b72
improved testing… (#301)
Byron Apr 27, 2022
2010ddd
more tests and fixes to assure directory logic in stack works (#301)
Byron Apr 27, 2022
e68cd69
Allow check-ignore style queries with API that doesn't remove trailin…
Byron Apr 27, 2022
6793bab
The stack now allows to change a non-dir into a dir (#301)
Byron Apr 27, 2022
120675d
Test for case-sensitivity as well (#301)
Byron Apr 27, 2022
a331314
frame for `gix repo exclude query` (#301)
Byron Apr 28, 2022
3ff991d
refactor (#301)
Byron Apr 28, 2022
732f6fb
a sketch of basic Worktree support (#301)
Byron Apr 28, 2022
ff76261
sketch `open_index()` on `Worktree`, but… (#301)
Byron Apr 28, 2022
13554f8
feat: new hierarchical errors for value lookup (#301)
Byron Apr 28, 2022
f9aaac1
change!: use `lookup::Error` and `lookup::existing::Error` (#301)
Byron Apr 28, 2022
d011d4e
thanks clippy
Byron Apr 28, 2022
a86b254
change!: remove all `get_` prefixes from methods (#301)
Byron Apr 28, 2022
61ea4c4
Adapt to changes in git-config (#301)
Byron Apr 28, 2022
cb56f12
fix build (#301)
Byron Apr 28, 2022
ca019fc
Release git-path v0.1.0
Byron Apr 28, 2022
8aef1d3
remove all #[inline] attributes (#301)
Byron Apr 28, 2022
a98a7a7
change!: switch from quickerror to thiserror. (#301)
Byron Apr 28, 2022
1e2b239
thanks clippy
Byron Apr 28, 2022
4496b5a
fix build warnings (#301)
Byron Apr 28, 2022
dc3dc3b
feat: support for `try_value()`, `boolean()` and `string()` access`. …
Byron Apr 28, 2022
ffc5dec
Adjust to improvements to the `git-config` API (#301)
Byron Apr 28, 2022
53f27e0
thanks clippy
Byron Apr 28, 2022
732c0fa
Remove IntegerSuffix error which wasn't ever used (#301)
Byron Apr 28, 2022
f11cc44
A first version of opening index files with proper configuration (#301)
Byron Apr 28, 2022
4612fca
A sketch of what can be a general value decode error (#301)
Byron Apr 28, 2022
807b7f8
refactor (#301)
Byron Apr 28, 2022
38dfdcf
change!: remove `values::*Error` in favor of `value::parse::Error`. (…
Byron Apr 28, 2022
2672a25
some tests to check pattern negation (#301)
Byron Apr 28, 2022
455a72e
feat: `fmt::Display` impl for `Pattern`. (#301)
Byron Apr 28, 2022
d29932d
make use of new git-glob::Pattern::to_string() feature (#301)
Byron Apr 28, 2022
a86ed7b
refactor (#301)
Byron Apr 28, 2022
d0c8407
Turn attribute files into a Cow to support other usecases… (#301)
Byron Apr 28, 2022
ed7f223
Revert "Turn attribute files into a Cow to support other usecases… (#…
Byron Apr 28, 2022
7c75eac
feat: `GitConfig::path()` for direct access to paths. (#301)
Byron Apr 28, 2022
8ab219a
feat: `State::path_backing()`. (#301)
Byron Apr 28, 2022
259d015
preliminary access to a fully configured exclusion cache (#301)
Byron Apr 28, 2022
5bf6b52
thanks clippy
Byron Apr 28, 2022
7d98b21
Support for overrides on the command-line (#301)
Byron Apr 29, 2022
de0226a
feat: `permission::Error` (#301)
Byron Apr 29, 2022
97e53f6
Some notes about of 'path' will soon have to be amended with more saf…
Byron Apr 29, 2022
95577e2
feat: A shared `permission::Error` type (#301)
Byron Apr 29, 2022
42a6c8c
Permission controlled access to xdg config (#301)
Byron Apr 29, 2022
a89a667
refactor (#301)
Byron Apr 29, 2022
f802a03
thanks clippy
Byron Apr 29, 2022
cb1c80f
fix build (#301)
Byron Apr 29, 2022
9cb8385
Basic prefix support as well the first working version of `exclude qu…
Byron Apr 29, 2022
e4f4c4b
`path::discover()` now returns the shortest path. (#301)
Byron Apr 29, 2022
09f904b
Add `--show-ignore-patterns` to `gix repo exclude query` (#301)
Byron Apr 30, 2022
7697f51
see if this fixes the CI test issue on windows (#301)
Byron Apr 30, 2022
0c597fe
Allow reading patterns from stdin (#301)
Byron Apr 30, 2022
056e8d2
thanks clippy
Byron Apr 30, 2022
b0b3df4
REMOVE ME: debug info for failing CI test (#301)
Byron Apr 30, 2022
3a41d5c
Don't have expectations on the path, rather deal with it gracefully (…
Byron Apr 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ members = [
"git-lock",
"git-attributes",
"git-pathspec",
"git-path",
"git-repository",
"gitoxide-core",
"git-tui",
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili
* **mailmap**
* [x] **verify** - check entries of a mailmap file for parse errors and display them
* **repository**
* **exclude**
* [x] **query** - check if path specs are excluded via gits exclusion rules like `.gitignore`.
* **verify** - validate a whole repository, for now only the object database.
* **commit**
* [x] **describe** - identify a commit by its closest tag in its past
Expand Down Expand Up @@ -122,6 +124,7 @@ Crates that seem feature complete and need to see some more use before they can
* [git-bitmap](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-bitmap)
* [git-revision](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-revision)
* [git-attributes](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-attributes)
* [git-path](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-path)
* **idea**
* [git-note](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-note)
* [git-filter](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-filter)
Expand Down
10 changes: 9 additions & 1 deletion crate-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ Check out the [performance discussion][git-traverse-performance] as well.
* [x] parsing
* [x] lookup and mapping of author names

### git-path
* [x] transformations to and from bytes
* [x] conversions between different platforms
* **spec**
* [ ] parse
* [ ] check for match

### git-pathspec
* [ ] parse
* [ ] check for match
Expand Down Expand Up @@ -429,7 +436,8 @@ See its [README.md](https://github.com/Byron/gitoxide/blob/main/git-lock/README.
* **refs**
* [ ] run transaction hooks and handle special repository states like quarantine
* [ ] support for different backends like `files` and `reftable`
* [ ] worktrees
* **worktrees**
* [ ] open a repository with worktrees
* [ ] remotes with push and pull
* [x] mailmap
* [x] object replacements (`git replace`)
Expand Down
3 changes: 2 additions & 1 deletion etc/check-package-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ echo "in root: gitoxide CLI"
(enter cargo-smart-release && indent cargo diet -n --package-size-limit 90KB)
(enter git-actor && indent cargo diet -n --package-size-limit 5KB)
(enter git-pathspec && indent cargo diet -n --package-size-limit 5KB)
(enter git-path && indent cargo diet -n --package-size-limit 10KB)
(enter git-attributes && indent cargo diet -n --package-size-limit 10KB)
(enter git-index && indent cargo diet -n --package-size-limit 30KB)
(enter git-worktree && indent cargo diet -n --package-size-limit 25KB)
Expand Down Expand Up @@ -51,6 +52,6 @@ echo "in root: gitoxide CLI"
(enter git-odb && indent cargo diet -n --package-size-limit 120KB)
(enter git-protocol && indent cargo diet -n --package-size-limit 50KB)
(enter git-packetline && indent cargo diet -n --package-size-limit 35KB)
(enter git-repository && indent cargo diet -n --package-size-limit 90KB)
(enter git-repository && indent cargo diet -n --package-size-limit 100KB)
(enter git-transport && indent cargo diet -n --package-size-limit 50KB)
(enter gitoxide-core && indent cargo diet -n --package-size-limit 70KB)
4 changes: 3 additions & 1 deletion git-attributes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ doctest = false

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

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

[dependencies]
git-features = { version = "^0.20.0", path = "../git-features" }
git-path = { version = "^0.1.0", path = "../git-path" }
git-quote = { version = "^0.2.0", path = "../git-quote" }
git-glob = { version = "^0.2.0", path = "../git-glob" }

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

[dev-dependencies]
git-testtools = { path = "../tests/tools"}
127 changes: 61 additions & 66 deletions git-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
#![deny(rust_2018_idioms)]

use bstr::{BStr, BString};
use compact_str::CompactStr;
use std::path::PathBuf;

pub use git_glob as glob;

/// The state an attribute can be in, referencing the value.
///
/// Note that this doesn't contain the name.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum State<'a> {
pub enum StateRef<'a> {
/// The attribute is listed, or has the special value 'true'
Set,
/// The attribute has the special value 'false', or was prefixed with a `-` sign.
Expand All @@ -18,87 +25,75 @@ pub enum State<'a> {
Unspecified,
}

/// A grouping of lists of patterns while possibly keeping associated to their base path.
/// The state an attribute can be in, owning the value.
///
/// Patterns with base path are queryable relative to that base, otherwise they are relative to the repository root.
/// Note that this doesn't contain the name.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum State {
/// The attribute is listed, or has the special value 'true'
Set,
/// The attribute has the special value 'false', or was prefixed with a `-` sign.
Unset,
/// The attribute is set to the given value, which followed the `=` sign.
/// Note that values can be empty.
Value(compact_str::CompactStr),
/// The attribute isn't mentioned with a given path or is explicitly set to `Unspecified` using the `!` sign.
Unspecified,
}

/// Name an attribute and describe it's assigned state.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
pub struct MatchGroup<T: match_group::Tag> {
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Assignment {
/// The name of the attribute.
pub name: CompactStr,
/// The state of the attribute.
pub state: State,
}

/// A grouping of lists of patterns while possibly keeping associated to their base path.
///
/// Pattern lists with base path are queryable relative to that base, otherwise they are relative to the repository root.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Default)]
pub struct MatchGroup<T: match_group::Pattern = Attributes> {
/// A list of pattern lists, each representing a patterns from a file or specified by hand, in the order they were
/// specified in.
///
/// During matching, this order is reversed.
pub patterns: Vec<PatternList<T>>,
}

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

/// The path at which the patterns are located in a format suitable for matches, or `None` if the patterns
/// are relative to the worktree root.
base: Option<BString>,
}

mod match_group {
use crate::{MatchGroup, PatternList};
use std::ffi::OsString;
use std::path::PathBuf;

/// A marker trait to identify the type of a description.
pub trait Tag: Clone + PartialEq + Eq + std::fmt::Debug + std::hash::Hash + Ord + PartialOrd {
/// The value associated with a pattern.
type Value: PartialEq + Eq + std::fmt::Debug + std::hash::Hash + Ord + PartialOrd + Clone;
}

/// Identify ignore patterns.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
pub struct Ignore;
impl Tag for Ignore {
type Value = ();
}
/// The path from which the patterns were read, or `None` if the patterns
/// don't originate in a file on disk.
pub source: Option<PathBuf>,

/// Identify patterns with attributes.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
pub struct Attributes;
impl Tag for Attributes {
/// TODO: identify the actual value, should be name/State pairs, but there is the question of storage.
type Value = ();
}

impl MatchGroup<Ignore> {
/// See [PatternList::<Ignore>::from_overrides()] for details.
pub fn from_overrides(patterns: impl IntoIterator<Item = impl Into<OsString>>) -> Self {
MatchGroup {
patterns: vec![PatternList::<Ignore>::from_overrides(patterns)],
}
}
}
/// The parent directory of source, or `None` if the patterns are _global_ to match against the repository root.
/// It's processed to contain slashes only and to end with a trailing slash, and is relative to the repository root.
pub base: Option<BString>,
}

impl PatternList<Ignore> {
/// Parse a list of patterns, using slashes as path separators
pub fn from_overrides(patterns: impl IntoIterator<Item = impl Into<OsString>>) -> Self {
PatternList {
patterns: patterns
.into_iter()
.map(Into::into)
.filter_map(|pattern| {
let pattern = git_features::path::into_bytes(PathBuf::from(pattern)).ok()?;
git_glob::parse(pattern.as_ref()).map(|p| (p, ()))
})
.collect(),
base: None,
}
}
}
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
pub struct PatternMapping<T> {
pub pattern: git_glob::Pattern,
pub value: T,
pub sequence_number: usize,
}
pub use match_group::{Attributes, Ignore, Tag};

pub type Files = MatchGroup<Attributes>;
pub type IgnoreFiles = MatchGroup<Ignore>;
mod match_group;
pub use match_group::{Attributes, Ignore, Match, Pattern};

pub mod parse;

Expand Down
Loading