Skip to content

Commit 741b41e

Browse files
committed
fix!: remove regex feature in favor of revparse-regex.
`revparse-regex` is only used when parsing revspecs that use a special syntax. This feature is also enabled by default.
1 parent 374dee6 commit 741b41e

File tree

6 files changed

+31
-27
lines changed

6 files changed

+31
-27
lines changed

gix/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ default = ["max-performance-safe", "comfort", "extras"]
5858
#! Bundles are for convenience only and bear no further meaning beyond the cargo manifest file.
5959

6060
## Various additional features and capabilities that are not necessarily part of what most users would need.
61-
extras = ["worktree-stream", "worktree-archive", "blob-diff", "revision"]
61+
extras = ["worktree-stream", "worktree-archive", "blob-diff", "revision", "revparse-regex"]
6262

6363
## Various progress-related features that improve the look of progress message units.
6464
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
@@ -71,6 +71,10 @@ comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human
7171
## Make revspec parsing possible, as well describing revision.
7272
revision = ["gix-revision/describe"]
7373

74+
## If enabled, revspecs now support the regex syntax like `@^{/^.*x}`. Otherwise, only substring search is supported.
75+
## This feature does increase compile time for niche-benefit, but is required for fully git-compatible revspec parsing.
76+
revparse-regex = ["regex", "revision"]
77+
7478
## Make it possible to diff blobs line by line. Note that this feature is integral for implementing tree-diffs as well due to the handling of rename-tracking,
7579
## which relies on line-by-line diffs in some cases.
7680
blob-diff = ["gix-diff/blob"]

gix/src/revision/spec/parse/delegate/navigate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
157157
self.unset_disambiguate_call();
158158
self.follow_refs_to_objects_if_needed()?;
159159

160-
#[cfg(not(feature = "regex"))]
160+
#[cfg(not(feature = "revparse-regex"))]
161161
let matches = |message: &BStr| -> bool { message.contains_str(regex) ^ negated };
162-
#[cfg(feature = "regex")]
162+
#[cfg(feature = "revparse-regex")]
163163
let matches = match regex::bytes::Regex::new(regex.to_str_lossy().as_ref()) {
164164
Ok(compiled) => {
165165
let needs_regex = regex::escape(compiled.as_str()) != regex;

gix/src/revision/spec/parse/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ pub enum Error {
100100
RevWalkIterInit(#[from] crate::reference::iter::init::Error),
101101
#[error(transparent)]
102102
RevWalkAllReferences(#[from] gix_ref::packed::buffer::open::Error),
103-
#[cfg(feature = "regex")]
103+
#[cfg(feature = "revparse-regex")]
104104
#[error(transparent)]
105105
InvalidRegex(#[from] regex::Error),
106106
#[cfg_attr(
107-
feature = "regex",
107+
feature = "revparse-regex",
108108
error("None of {commits_searched} commits from {oid} matched regex {regex:?}")
109109
)]
110110
#[cfg_attr(
111-
not(feature = "regex"),
111+
not(feature = "revparse-regex"),
112112
error("None of {commits_searched} commits from {oid} matched text {regex:?}")
113113
)]
114114
NoRegexMatch {
@@ -117,11 +117,11 @@ pub enum Error {
117117
commits_searched: usize,
118118
},
119119
#[cfg_attr(
120-
feature = "regex",
120+
feature = "revparse-regex",
121121
error("None of {commits_searched} commits reached from all references matched regex {regex:?}")
122122
)]
123123
#[cfg_attr(
124-
not(feature = "regex"),
124+
not(feature = "revparse-regex"),
125125
error("None of {commits_searched} commits reached from all references matched text {regex:?}")
126126
)]
127127
NoRegexMatchAllRefs { regex: BString, commits_searched: usize },

gix/tests/gix.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
#[cfg(not(feature = "regex"))]
1+
#[cfg(not(feature = "revparse-regex"))]
22
mod util;
3-
#[cfg(not(feature = "regex"))]
3+
#[cfg(not(feature = "revparse-regex"))]
44
use util::*;
55

6-
#[cfg(not(feature = "regex"))]
6+
#[cfg(not(feature = "revparse-regex"))]
77
mod clone;
8-
#[cfg(not(feature = "regex"))]
8+
#[cfg(not(feature = "revparse-regex"))]
99
mod commit;
10-
#[cfg(not(feature = "regex"))]
10+
#[cfg(not(feature = "revparse-regex"))]
1111
mod config;
12-
#[cfg(not(feature = "regex"))]
12+
#[cfg(not(feature = "revparse-regex"))]
1313
mod head;
14-
#[cfg(not(feature = "regex"))]
14+
#[cfg(not(feature = "revparse-regex"))]
1515
mod id;
16-
#[cfg(not(feature = "regex"))]
16+
#[cfg(not(feature = "revparse-regex"))]
1717
mod init;
18-
#[cfg(not(feature = "regex"))]
18+
#[cfg(not(feature = "revparse-regex"))]
1919
mod object;
20-
#[cfg(not(feature = "regex"))]
20+
#[cfg(not(feature = "revparse-regex"))]
2121
mod reference;
22-
#[cfg(not(feature = "regex"))]
22+
#[cfg(not(feature = "revparse-regex"))]
2323
mod remote;
24-
#[cfg(not(feature = "regex"))]
24+
#[cfg(not(feature = "revparse-regex"))]
2525
mod repository;
26-
#[cfg(not(feature = "regex"))]
26+
#[cfg(not(feature = "revparse-regex"))]
2727
#[cfg(feature = "revision")]
2828
mod revision;
29-
#[cfg(not(feature = "regex"))]
29+
#[cfg(not(feature = "revparse-regex"))]
3030
mod submodule;

gix/tests/revision/spec/from_bytes/regex.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod with_known_revision {
1212
use crate::revision::spec::from_bytes::parse_spec;
1313

1414
#[test]
15-
#[cfg(not(feature = "regex"))]
15+
#[cfg(not(feature = "revparse-regex"))]
1616
fn contained_string_matches_in_unanchored_regex_and_disambiguates_automatically() {
1717
let repo = repo("ambiguous_blob_tree_commit").unwrap();
1818
let expected = Spec::from_id(hex_to_id("0000000000e4f9fbd19cf1e932319e5ad0d1d00b").attach(&repo));
@@ -28,7 +28,7 @@ mod with_known_revision {
2828
}
2929

3030
#[test]
31-
#[cfg(feature = "regex")]
31+
#[cfg(feature = "revparse-regex")]
3232
fn contained_string_matches_in_unanchored_regex_and_disambiguates_automatically() {
3333
let repo = repo("ambiguous_blob_tree_commit").unwrap();
3434
let expected = Spec::from_id(hex_to_id("0000000000e4f9fbd19cf1e932319e5ad0d1d00b").attach(&repo));
@@ -63,7 +63,7 @@ mod find_youngest_matching_commit {
6363
use crate::revision::spec::from_bytes::parse_spec;
6464

6565
#[test]
66-
#[cfg(not(feature = "regex"))]
66+
#[cfg(not(feature = "revparse-regex"))]
6767
fn contained_string_matches() {
6868
let repo = repo("complex_graph").unwrap();
6969

@@ -91,7 +91,7 @@ mod find_youngest_matching_commit {
9191
}
9292

9393
#[test]
94-
#[cfg(feature = "regex")]
94+
#[cfg(feature = "revparse-regex")]
9595
fn regex_matches() {
9696
let repo = repo("complex_graph").unwrap();
9797

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ check:
116116
cargo check -p gix --no-default-features --features progress-tree
117117
cargo check -p gix --no-default-features --features blob-diff
118118
cargo check -p gix --no-default-features --features revision
119+
cargo check -p gix --no-default-features --features revparse-regex
119120
cargo check -p gix --no-default-features
120121
cargo check -p gix-odb --features serde
121122
cargo check --no-default-features --features max-control
@@ -158,7 +159,6 @@ unit-tests:
158159
cargo test -p gix --no-default-features
159160
cargo test -p gix --features async-network-client
160161
cargo test -p gix --features blocking-network-client
161-
cargo test -p gix --features regex
162162
cargo test -p gitoxide-core --lib
163163

164164
# These tests aren't run by default as they are flaky (even locally)

0 commit comments

Comments
 (0)