History

refactor

Sebastian Thiel committed 4 years ago

Commit 162f9a01 parent 0bed9382 files · +183 −179Browse files

Showing the changes to git-pathspec/src (1 of 2 files). Show all

Unified · Split

git-pathspec/src/parse.rs+7−11
@@ -7,18 +7,14 @@ use crate::{MagicSignature, Pattern, SearchMode}; · 6 unmodified lines
7pub enum Error {7pub enum Error {
8 #[error("Empty string is not a valid pathspec")]8 #[error("Empty string is not a valid pathspec")]
9 EmptyString,9 EmptyString,
10 10 #[error("Found {:?}, which is not a valid keyword", found_keyword)]
11 #[error("Found \"{}\", which is not a valid keyword", found_keyword)]
12 InvalidKeyword { found_keyword: BString },11 InvalidKeyword { found_keyword: BString },
13 12 #[error("Missing ')' at the end of pathspec magic in {:?}", pathspec)]
14 #[error("Missing ')' at the end of pathspec magic in '{}'", pathspec)]
15 MissingClosingParenthesis { pathspec: BString },13 MissingClosingParenthesis { pathspec: BString },
16 14 #[error("Attribute has non-ascii characters or starts with '-': {:?}", attribute)]
17 #[error("Attribute has non-ascii characters or starts with '-': {}", attribute)]
18 InvalidAttribute { attribute: BString },15 InvalidAttribute { attribute: BString },
19 16 #[error("'literal' and 'glob' keywords cannot be used together in the same pathspec")]
20 #[error("'literal' and 'globl' keywords can not be used together in the same pathspec")]17 IncompatibleSearchModes,
21 IncompatibleSearchmodes,
22}18}
23 19
24impl Pattern {20impl Pattern {
@@ -94,11 +90,11 @@ fn parse_keywords(input: &[u8]) -> Result<(MagicSignature, SearchMode, Vec<(BStr · 69 unmodified lines
94 b"attr" => signature |= MagicSignature::ATTR,90 b"attr" => signature |= MagicSignature::ATTR,
95 b"literal" => match searchmode {91 b"literal" => match searchmode {
96 SearchMode::Default => searchmode = SearchMode::Literal,92 SearchMode::Default => searchmode = SearchMode::Literal,
97 _ => return Err(Error::IncompatibleSearchmodes),93 _ => return Err(Error::IncompatibleSearchModes),
98 },94 },
99 b"glob" => match searchmode {95 b"glob" => match searchmode {
100 SearchMode::Default => searchmode = SearchMode::Glob,96 SearchMode::Default => searchmode = SearchMode::Glob,
101 _ => return Err(Error::IncompatibleSearchmodes),97 _ => return Err(Error::IncompatibleSearchModes),
102 },98 },
103 s => {99 s => {
104 if let Some(attrs) = s.strip_prefix(b"attr:") {100 if let Some(attrs) = s.strip_prefix(b"attr:") {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t