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
84ce9746
Unverified
Commit
84ce9746
authored
Jul 14, 2021
by
Edward Thomson
Committed by
GitHub
Jul 14, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5824 from palmin/fix-ignore-negate
fix check for ignoring of negate rules
parents
e5649e10
6d2a6f3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
src/ignore.c
+11
-3
tests/ignore/path.c
+8
-0
No files found.
src/ignore.c
View file @
84ce9746
...
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
...
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
*/
*/
static
int
does_negate_rule
(
int
*
out
,
git_vector
*
rules
,
git_attr_fnmatch
*
match
)
static
int
does_negate_rule
(
int
*
out
,
git_vector
*
rules
,
git_attr_fnmatch
*
match
)
{
{
int
error
=
0
,
wildmatch_flags
;
int
error
=
0
,
wildmatch_flags
,
effective_flags
;
size_t
i
;
size_t
i
;
git_attr_fnmatch
*
rule
;
git_attr_fnmatch
*
rule
;
char
*
path
;
char
*
path
;
...
@@ -141,8 +141,17 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
...
@@ -141,8 +141,17 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
if
(
git_buf_oom
(
&
buf
))
if
(
git_buf_oom
(
&
buf
))
goto
out
;
goto
out
;
/*
* if rule isn't for full path we match without PATHNAME flag
* as lines like *.txt should match something like dir/test.txt
* requiring * to also match /
*/
effective_flags
=
wildmatch_flags
;
if
(
!
(
rule
->
flags
&
GIT_ATTR_FNMATCH_FULLPATH
))
effective_flags
&=
~
WM_PATHNAME
;
/* if we found a match, we want to keep this rule */
/* if we found a match, we want to keep this rule */
if
((
wildmatch
(
git_buf_cstr
(
&
buf
),
path
,
wildmatch
_flags
))
==
WM_MATCH
)
{
if
((
wildmatch
(
git_buf_cstr
(
&
buf
),
path
,
effective
_flags
))
==
WM_MATCH
)
{
*
out
=
1
;
*
out
=
1
;
error
=
0
;
error
=
0
;
goto
out
;
goto
out
;
...
@@ -639,4 +648,3 @@ int git_ignore__check_pathspec_for_exact_ignores(
...
@@ -639,4 +648,3 @@ int git_ignore__check_pathspec_for_exact_ignores(
return
error
;
return
error
;
}
}
tests/ignore/path.c
View file @
84ce9746
...
@@ -575,3 +575,11 @@ void test_ignore_path__negative_prefix_rule(void)
...
@@ -575,3 +575,11 @@ void test_ignore_path__negative_prefix_rule(void)
assert_is_ignored
(
true
,
"ff"
);
assert_is_ignored
(
true
,
"ff"
);
assert_is_ignored
(
false
,
"f"
);
assert_is_ignored
(
false
,
"f"
);
}
}
void
test_ignore_path__negative_more_specific
(
void
)
{
cl_git_rewritefile
(
"attr/.gitignore"
,
"*.txt
\n
!/dir/test.txt
\n
"
);
assert_is_ignored
(
true
,
"test.txt"
);
assert_is_ignored
(
false
,
"dir/test.txt"
);
assert_is_ignored
(
true
,
"outer/dir/test.txt"
);
}
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