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
b4e5432f
Commit
b4e5432f
authored
Nov 05, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2688 from libgit2/cmn/ignore-file-trailing-cr
ignore: consider files with a CR in their names
parents
3f8d005a
5c54e216
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletions
+42
-1
src/attr_file.c
+10
-1
tests/status/ignore.c
+32
-0
No files found.
src/attr_file.c
View file @
b4e5432f
...
...
@@ -543,7 +543,7 @@ int git_attr_fnmatch__parse(
for
(
scan
=
pattern
;
*
scan
!=
'\0'
;
++
scan
)
{
/* scan until (non-escaped) white space */
if
(
git__isspace
(
*
scan
)
&&
*
(
scan
-
1
)
!=
'\\'
)
{
if
(
!
allow_space
||
(
*
scan
!=
' '
&&
*
scan
!=
'\t'
))
if
(
!
allow_space
||
(
*
scan
!=
' '
&&
*
scan
!=
'\t'
&&
*
scan
!=
'\r'
))
break
;
}
...
...
@@ -564,6 +564,15 @@ int git_attr_fnmatch__parse(
if
((
spec
->
length
=
scan
-
pattern
)
==
0
)
return
GIT_ENOTFOUND
;
/*
* Remove one trailing \r in case this is a CRLF delimited
* file, in the case of Icon\r\r\n, we still leave the first
* \r there to match against.
*/
if
(
pattern
[
spec
->
length
-
1
]
==
'\r'
)
if
(
--
spec
->
length
==
0
)
return
GIT_ENOTFOUND
;
if
(
pattern
[
spec
->
length
-
1
]
==
'/'
)
{
spec
->
length
--
;
spec
->
flags
=
spec
->
flags
|
GIT_ATTR_FNMATCH_DIRECTORY
;
...
...
tests/status/ignore.c
View file @
b4e5432f
...
...
@@ -883,3 +883,35 @@ void test_status_ignore__negative_ignores_without_trailing_slash_inside_ignores(
cl_assert
(
found_parent_child2_file
);
}
void
test_status_ignore__filename_with_cr
(
void
)
{
int
ignored
;
g_repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"Icon
\r\r\n
"
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Icon
\r
"
));
cl_assert_equal_i
(
1
,
ignored
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"Ico
\r
n
\n
"
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Ico
\r
n"
));
cl_assert_equal_i
(
1
,
ignored
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"Ico
\r
n
\r\n
"
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Ico
\r
n"
));
cl_assert_equal_i
(
1
,
ignored
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Ico
\r
n
\r
"
));
cl_assert_equal_i
(
0
,
ignored
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"Ico
\r
n
\r\r\n
"
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Ico
\r
n
\r
"
));
cl_assert_equal_i
(
1
,
ignored
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Icon
\r
"
));
cl_assert_equal_i
(
0
,
ignored
);
cl_git_mkfile
(
"empty_standard_repo/.gitignore"
,
"Icon
\r\n
"
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Icon
\r
"
));
cl_assert_equal_i
(
0
,
ignored
);
cl_git_pass
(
git_ignore_path_is_ignored
(
&
ignored
,
g_repo
,
"Icon"
));
cl_assert_equal_i
(
1
,
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