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
1e80bf27
Commit
1e80bf27
authored
Sep 13, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cmn/ignore-dir-check'
parents
305407e1
657afd35
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
src/ignore.c
+9
-7
tests/status/ignore.c
+17
-0
No files found.
src/ignore.c
View file @
1e80bf27
...
...
@@ -89,18 +89,20 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
}
/*
* If we're dealing with a directory (which we know via the
* strchr() check) we want to use 'dirname/<star>' as the
* pattern so p_fnmatch() honours FNM_PATHNAME
* When dealing with a directory, we add '/<star>' so
* p_fnmatch() honours FNM_PATHNAME. Checking for LEADINGDIR
* alone isn't enough as that's also set for nagations, so we
* need to check that NEGATIVE is off.
*/
git_buf_clear
(
&
buf
);
if
(
rule
->
containing_dir
)
{
git_buf_puts
(
&
buf
,
rule
->
containing_dir
);
}
if
(
!
strchr
(
rule
->
pattern
,
'*'
))
error
=
git_buf_printf
(
&
buf
,
"%s/*"
,
rule
->
pattern
);
else
error
=
git_buf_puts
(
&
buf
,
rule
->
pattern
);
error
=
git_buf_puts
(
&
buf
,
rule
->
pattern
);
if
((
rule
->
flags
&
(
GIT_ATTR_FNMATCH_LEADINGDIR
|
GIT_ATTR_FNMATCH_NEGATIVE
))
==
GIT_ATTR_FNMATCH_LEADINGDIR
)
error
=
git_buf_PUTS
(
&
buf
,
"/*"
);
if
(
error
<
0
)
goto
out
;
...
...
tests/status/ignore.c
View file @
1e80bf27
...
...
@@ -1022,3 +1022,20 @@ void test_status_ignore__negate_exact_previous(void)
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
".buildpath"
));
cl_assert_equal_i
(
1
,
ignored
);
}
void
test_status_ignore__negate_starstar
(
void
)
{
int
ignored
;
g_repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"code/projects/**/packages/*
\n
"
"!code/projects/**/packages/repositories.config"
);
cl_git_pass
(
git_futils_mkdir_r
(
"code/projects/foo/bar/packages"
,
"empty_standard_repo"
,
0777
));
cl_git_mkfile
(
"empty_standard_repo/code/projects/foo/bar/packages/repositories.config"
,
""
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"code/projects/foo/bar/packages/repositories.config"
));
cl_assert_equal_i
(
0
,
ignored
);
}
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