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
68fec637
Commit
68fec637
authored
Feb 22, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1356 from arrbee/fix-directory-as-ignore-file
Do not fail if .gitignore is directory
parents
7beeb3f4
37d91686
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
src/attr.c
+8
-2
tests-clar/attr/ignore.c
+27
-11
No files found.
src/attr.c
View file @
68fec637
...
...
@@ -278,8 +278,14 @@ static int load_attr_file(
return
GIT_ENOTFOUND
;
error
=
git_futils_readbuffer
(
&
content
,
filename
);
if
(
error
<
0
)
return
error
;
if
(
error
<
0
)
{
/* convert error into ENOTFOUND so failed permissions / invalid
* file type don't actually stop the operation in progress.
*/
return
GIT_ENOTFOUND
;
/* TODO: once warnings are available, issue a warning callback */
}
*
data
=
git_buf_detach
(
&
content
);
...
...
tests-clar/attr/ignore.c
View file @
68fec637
#include "clar_libgit2.h"
#include "posix.h"
#include "path.h"
static
git_repository
*
g_repo
=
NULL
;
void
test_attr_ignore__initialize
(
void
)
{
g_repo
=
cl_git_sandbox_init
(
"attr"
);
g_repo
=
cl_git_sandbox_init
(
"attr"
);
}
void
test_attr_ignore__cleanup
(
void
)
{
cl_git_sandbox_cleanup
();
g_repo
=
NULL
;
cl_git_sandbox_cleanup
();
g_repo
=
NULL
;
}
void
assert_is_ignored
(
bool
expected
,
const
char
*
filepath
)
{
int
is_ignored
;
int
is_ignored
;
cl_git_pass
(
git_ignore_path_is_ignored
(
&
is_ignored
,
g_repo
,
filepath
));
cl_assert_equal_i
(
expected
,
is_ignored
==
1
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
is_ignored
,
g_repo
,
filepath
));
cl_assert_equal_i
(
expected
,
is_ignored
==
1
);
}
void
test_attr_ignore__honor_temporary_rules
(
void
)
{
cl_git_rewritefile
(
"attr/.gitignore"
,
"/NewFolder
\n
/NewFolder/NewFolder"
);
cl_git_rewritefile
(
"attr/.gitignore"
,
"/NewFolder
\n
/NewFolder/NewFolder"
);
assert_is_ignored
(
false
,
"File.txt"
);
assert_is_ignored
(
true
,
"NewFolder"
);
assert_is_ignored
(
true
,
"NewFolder/NewFolder"
);
assert_is_ignored
(
true
,
"NewFolder/NewFolder/File.txt"
);
assert_is_ignored
(
false
,
"File.txt"
);
assert_is_ignored
(
true
,
"NewFolder"
);
assert_is_ignored
(
true
,
"NewFolder/NewFolder"
);
assert_is_ignored
(
true
,
"NewFolder/NewFolder/File.txt"
);
}
void
test_attr_ignore__skip_gitignore_directory
(
void
)
{
cl_git_rewritefile
(
"attr/.git/info/exclude"
,
"/NewFolder
\n
/NewFolder/NewFolder"
);
p_unlink
(
"attr/.gitignore"
);
cl_assert
(
!
git_path_exists
(
"attr/.gitignore"
));
p_mkdir
(
"attr/.gitignore"
,
0777
);
cl_git_mkfile
(
"attr/.gitignore/garbage.txt"
,
"new_file
\n
"
);
assert_is_ignored
(
false
,
"File.txt"
);
assert_is_ignored
(
true
,
"NewFolder"
);
assert_is_ignored
(
true
,
"NewFolder/NewFolder"
);
assert_is_ignored
(
true
,
"NewFolder/NewFolder/File.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