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
82e929a8
Commit
82e929a8
authored
Jun 04, 2017
by
Edward Thomson
Committed by
GitHub
Jun 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4239 from roblg/toplevel-dir-ignore-fix
Fix issue with directory glob ignore in subdirectories
parents
04de614b
c3b8e8b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
2 deletions
+96
-2
src/attr_file.c
+6
-2
tests/attr/ignore.c
+12
-0
tests/status/ignore.c
+78
-0
No files found.
src/attr_file.c
View file @
82e929a8
...
...
@@ -395,9 +395,13 @@ bool git_attr_fnmatch__match(
if
((
match
->
flags
&
GIT_ATTR_FNMATCH_DIRECTORY
)
&&
!
path
->
is_dir
)
{
bool
samename
;
/* for attribute checks or root ignore checks, fail match */
/*
* for attribute checks or checks at the root of this match's
* containing_dir (or root of the repository if no containing_dir),
* do not match.
*/
if
(
!
(
match
->
flags
&
GIT_ATTR_FNMATCH_IGNORE
)
||
path
->
basename
==
path
->
path
)
path
->
basename
==
rel
path
)
return
false
;
flags
|=
FNM_LEADING_DIR
;
...
...
tests/attr/ignore.c
View file @
82e929a8
...
...
@@ -291,3 +291,15 @@ void test_attr_ignore__symlink_to_outside(void)
assert_is_ignored
(
true
,
"symlink"
);
assert_is_ignored
(
true
,
"lala/../symlink"
);
}
void
test_attr_ignore__test
(
void
)
{
cl_git_rewritefile
(
"attr/.gitignore"
,
"/*/
\n
"
"!/src
\n
"
);
assert_is_ignored
(
false
,
"src/foo.c"
);
assert_is_ignored
(
false
,
"src/foo/foo.c"
);
assert_is_ignored
(
false
,
"README.md"
);
assert_is_ignored
(
true
,
"dist/foo.o"
);
assert_is_ignored
(
true
,
"bin/foo"
);
}
tests/status/ignore.c
View file @
82e929a8
...
...
@@ -1077,3 +1077,81 @@ void test_status_ignore__negate_starstar(void)
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"code/projects/foo/bar/packages/repositories.config"
));
cl_assert_equal_i
(
0
,
ignored
);
}
void
test_status_ignore__ignore_all_toplevel_dirs_include_files
(
void
)
{
static
const
char
*
test_files
[]
=
{
"empty_standard_repo/README.md"
,
"empty_standard_repo/src/main.c"
,
"empty_standard_repo/src/foo/foo.c"
,
"empty_standard_repo/dist/foo.o"
,
"empty_standard_repo/dist/main.o"
,
NULL
};
make_test_data
(
"empty_standard_repo"
,
test_files
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"/*/
\n
"
"!/src
\n
"
);
assert_is_ignored
(
"dist/foo.o"
);
assert_is_ignored
(
"dist/main.o"
);
refute_is_ignored
(
"README.md"
);
refute_is_ignored
(
"src/foo.c"
);
refute_is_ignored
(
"src/foo/foo.c"
);
}
void
test_status_ignore__subdir_ignore_all_toplevel_dirs_include_files
(
void
)
{
static
const
char
*
test_files
[]
=
{
"empty_standard_repo/project/README.md"
,
"empty_standard_repo/project/src/main.c"
,
"empty_standard_repo/project/src/foo/foo.c"
,
"empty_standard_repo/project/dist/foo.o"
,
"empty_standard_repo/project/dist/main.o"
,
NULL
};
make_test_data
(
"empty_standard_repo"
,
test_files
);
cl_git_mkfile
(
"empty_standard_repo/project/.gitignore"
,
"/*/
\n
"
"!/src
\n
"
);
assert_is_ignored
(
"project/dist/foo.o"
);
assert_is_ignored
(
"project/dist/main.o"
);
refute_is_ignored
(
"project/src/foo.c"
);
refute_is_ignored
(
"project/src/foo/foo.c"
);
refute_is_ignored
(
"project/README.md"
);
}
void
test_status_ignore__subdir_ignore_everything_except_certain_files
(
void
)
{
static
const
char
*
test_files
[]
=
{
"empty_standard_repo/project/README.md"
,
"empty_standard_repo/project/some_file"
,
"empty_standard_repo/project/src/main.c"
,
"empty_standard_repo/project/src/foo/foo.c"
,
"empty_standard_repo/project/dist/foo.o"
,
"empty_standard_repo/project/dist/main.o"
,
NULL
};
make_test_data
(
"empty_standard_repo"
,
test_files
);
cl_git_mkfile
(
"empty_standard_repo/project/.gitignore"
,
"/*
\n
"
"!/src
\n
"
"!README.md
\n
"
);
assert_is_ignored
(
"project/some_file"
);
assert_is_ignored
(
"project/dist/foo.o"
);
assert_is_ignored
(
"project/dist/main.o"
);
refute_is_ignored
(
"project/README.md"
);
refute_is_ignored
(
"project/src/foo.c"
);
refute_is_ignored
(
"project/src/foo/foo.c"
);
}
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