Skip to content

Commit d95f372

Browse files
CopilotByron
andcommitted
Address code review feedback
- Extract helper function `is_one_sided_glob_pattern` for better readability - Change `glob_count >= 1` to `glob_count > 0` with clarifying comment - All tests still passing Co-authored-by: Byron <[email protected]>
1 parent cb5979f commit d95f372

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

gix-refspec/src/parse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ pub(crate) mod function {
161161
return Err(Error::PatternUnsupported { pattern: spec.into() });
162162
}
163163
}
164-
let has_globs = glob_count >= 1;
164+
// Check if there are any globs (one or more asterisks)
165+
let has_globs = glob_count > 0;
165166
if has_globs {
166167
// For one-sided refspecs, skip validation of glob patterns
167168
if !is_one_sided {

gix-refspec/tests/refspec/parse/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn baseline() {
4646
true,
4747
) => {} // we prefer failing fast, git let's it pass
4848
// We now allow complex glob patterns in one-sided refspecs
49-
(None, false) if matches!(op, Operation::Fetch) && spec.to_str().map(|s| s.contains('*') && !s.contains(':')).unwrap_or(false) => {
49+
(None, false) if is_one_sided_glob_pattern(spec, op) => {
5050
// This is an intentional behavior change: we allow complex globs in one-sided refspecs
5151
}
5252
_ => {
@@ -70,6 +70,11 @@ fn baseline() {
7070
panics
7171
);
7272
}
73+
74+
fn is_one_sided_glob_pattern(spec: &[u8], op: Operation) -> bool {
75+
use bstr::ByteSlice;
76+
matches!(op, Operation::Fetch) && spec.to_str().map(|s| s.contains('*') && !s.contains(':')).unwrap_or(false)
77+
}
7378
}
7479

7580
#[test]

0 commit comments

Comments
 (0)