Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
95fbc81d
Commit
95fbc81d
authored
Apr 19, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3745 from libgit2/cmn/ignore-starstar
Improve star-star matching
parents
029c9346
d45928cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
5 deletions
+44
-5
src/fnmatch.c
+18
-5
tests/attr/ignore.c
+26
-0
No files found.
src/fnmatch.c
View file @
95fbc81d
...
...
@@ -93,11 +93,24 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
* It will be restored if/when we recurse below.
*/
if
(
c
==
'*'
)
{
flags
&=
~
FNM_PATHNAME
;
while
(
c
==
'*'
)
c
=
*++
pattern
;
if
(
c
==
'/'
)
c
=
*++
pattern
;
c
=
*++
pattern
;
/* star-star-slash is at the end, match by default */
if
(
c
==
EOS
)
return
0
;
/* Double-star must be at end or between slashes */
if
(
c
!=
'/'
)
return
(
FNM_NOMATCH
);
c
=
*++
pattern
;
do
{
int
e
=
p_fnmatchx
(
pattern
,
string
,
recurs_flags
,
recurs
);
if
(
e
!=
FNM_NOMATCH
)
return
e
;
string
=
strchr
(
string
,
'/'
);
}
while
(
string
++
);
/* If we get here, we didn't find a match */
return
FNM_NOMATCH
;
}
if
(
*
string
==
'.'
&&
(
flags
&
FNM_PERIOD
)
&&
...
...
tests/attr/ignore.c
View file @
95fbc81d
...
...
@@ -132,6 +132,32 @@ void test_attr_ignore__leading_stars(void)
assert_is_ignored
(
false
,
"dir1/kid2/file"
);
}
void
test_attr_ignore__globs_and_path_delimiters
(
void
)
{
cl_git_rewritefile
(
"attr/.gitignore"
,
"foo/bar/**"
);
assert_is_ignored
(
true
,
"foo/bar/baz"
);
assert_is_ignored
(
true
,
"foo/bar/baz/quux"
);
cl_git_rewritefile
(
"attr/.gitignore"
,
"_*/"
);
assert_is_ignored
(
true
,
"sub/_test/a/file"
);
assert_is_ignored
(
false
,
"test_folder/file"
);
assert_is_ignored
(
true
,
"_test/file"
);
assert_is_ignored
(
true
,
"_test/a/file"
);
cl_git_rewritefile
(
"attr/.gitignore"
,
"**/_*/"
);
assert_is_ignored
(
true
,
"sub/_test/a/file"
);
assert_is_ignored
(
false
,
"test_folder/file"
);
assert_is_ignored
(
true
,
"_test/file"
);
assert_is_ignored
(
true
,
"_test/a/file"
);
cl_git_rewritefile
(
"attr/.gitignore"
,
"**/_*/foo/bar/*ux"
);
assert_is_ignored
(
true
,
"sub/_test/foo/bar/qux/file"
);
assert_is_ignored
(
true
,
"_test/foo/bar/qux/file"
);
assert_is_ignored
(
true
,
"_test/foo/bar/crux/file"
);
assert_is_ignored
(
false
,
"_test/foo/bar/code/file"
);
}
void
test_attr_ignore__skip_gitignore_directory
(
void
)
{
cl_git_rewritefile
(
"attr/.git/info/exclude"
,
"/NewFolder
\n
/NewFolder/NewFolder"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment