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
7be1caf7
Commit
7be1caf7
authored
Apr 07, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Determine crlf safety by statistics, not literal reversibility
parent
855c66de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
24 deletions
+9
-24
src/crlf.c
+9
-24
No files found.
src/crlf.c
View file @
7be1caf7
...
...
@@ -124,9 +124,6 @@ static int crlf_apply_to_odb(
const
git_buf
*
from
,
const
git_filter_source
*
src
)
{
git_buf
safe
=
GIT_BUF_INIT
;
int
error
=
0
;
/* Empty file? Nothing to do */
if
(
!
git_buf_len
(
from
))
return
0
;
...
...
@@ -141,6 +138,13 @@ static int crlf_apply_to_odb(
if
(
git_buf_text_gather_stats
(
&
stats
,
from
,
false
))
return
GIT_PASSTHROUGH
;
/* If safecrlf is enabled, sanity-check the result. */
if
(
ca
->
safe_crlf
&&
(
stats
.
cr
!=
stats
.
crlf
||
stats
.
lf
!=
stats
.
crlf
))
{
giterr_set
(
GITERR_FILTER
,
"LF would be replaced by CRLF in '%s'"
,
git_filter_source_path
(
src
));
return
-
1
;
}
/*
* We're currently not going to even try to convert stuff
* that has bare CR characters. Does anybody do that crazy
...
...
@@ -158,31 +162,12 @@ static int crlf_apply_to_odb(
return
GIT_PASSTHROUGH
;
}
if
(
!
stats
.
cr
&&
!
ca
->
safe_crlf
)
if
(
!
stats
.
cr
)
return
GIT_PASSTHROUGH
;
}
/* Actually drop the carriage returns */
if
((
error
=
git_buf_text_crlf_to_lf
(
to
,
from
))
<
0
)
return
error
;
/* If safecrlf is enabled, sanity-check the result. */
if
(
ca
->
safe_crlf
)
{
if
((
error
=
git_buf_grow
(
&
safe
,
max
(
from
->
size
,
to
->
size
)))
<
0
||
(
error
=
git_buf_text_lf_to_crlf
(
&
safe
,
to
))
<
0
)
goto
done
;
if
(
git_buf_cmp
(
from
,
&
safe
)
!=
0
)
{
giterr_set
(
GITERR_FILTER
,
"LF would be replaced by CRLF in '%s'"
,
git_filter_source_path
(
src
));
error
=
-
1
;
}
}
done:
git_buf_free
(
&
safe
);
return
error
;
return
git_buf_text_crlf_to_lf
(
to
,
from
);
}
static
const
char
*
line_ending
(
struct
crlf_attrs
*
ca
)
...
...
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