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
4aa36ff2
Unverified
Commit
4aa36ff2
authored
May 21, 2019
by
Patrick Steinhardt
Committed by
GitHub
May 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5075 from libgit2/ethomson/ignore_skip_bom
Skip UTF8 BOM in ignore files
parents
6b9cc029
133bceba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletions
+35
-1
src/attr_file.c
+12
-1
tests/status/ignore.c
+23
-0
No files found.
src/attr_file.c
View file @
4aa36ff2
...
...
@@ -10,6 +10,7 @@
#include "repository.h"
#include "filebuf.h"
#include "attrcache.h"
#include "buf_text.h"
#include "git2/blob.h"
#include "git2/tree.h"
#include "blob.h"
...
...
@@ -108,9 +109,12 @@ int git_attr_file__load(
int
error
=
0
;
git_blob
*
blob
=
NULL
;
git_buf
content
=
GIT_BUF_INIT
;
const
char
*
content_str
;
git_attr_file
*
file
;
struct
stat
st
;
bool
nonexistent
=
false
;
int
bom_offset
;
git_bom_t
bom
;
*
out
=
NULL
;
...
...
@@ -159,13 +163,20 @@ int git_attr_file__load(
if
((
error
=
git_attr_file__new
(
&
file
,
entry
,
source
))
<
0
)
goto
cleanup
;
/* advance over a UTF8 BOM */
content_str
=
git_buf_cstr
(
&
content
);
bom_offset
=
git_buf_text_detect_bom
(
&
bom
,
&
content
);
if
(
bom
==
GIT_BOM_UTF8
)
content_str
+=
bom_offset
;
/* store the key of the attr_reader; don't bother with cache
* invalidation during the same attr reader session.
*/
if
(
attr_session
)
file
->
session_key
=
attr_session
->
key
;
if
(
parser
&&
(
error
=
parser
(
repo
,
file
,
git_buf_cstr
(
&
content
)
))
<
0
)
{
if
(
parser
&&
(
error
=
parser
(
repo
,
file
,
content_str
))
<
0
)
{
git_attr_file__free
(
file
);
goto
cleanup
;
}
...
...
tests/status/ignore.c
View file @
4aa36ff2
...
...
@@ -1213,3 +1213,26 @@ void test_status_ignore__unignored_subdirs(void)
assert_is_ignored
(
"dir/a.test"
);
refute_is_ignored
(
"dir/subdir/a.test"
);
}
void
test_status_ignore__skips_bom
(
void
)
{
static
const
char
*
test_files
[]
=
{
"empty_standard_repo/a.test"
,
"empty_standard_repo/b.test"
,
"empty_standard_repo/c.test"
,
"empty_standard_repo/foo.txt"
,
"empty_standard_repo/bar.txt"
,
NULL
};
make_test_data
(
"empty_standard_repo"
,
test_files
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"
\xEF\xBB\xBF
*.test
\n
"
);
assert_is_ignored
(
"a.test"
);
assert_is_ignored
(
"b.test"
);
assert_is_ignored
(
"c.test"
);
refute_is_ignored
(
"foo.txt"
);
refute_is_ignored
(
"bar.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