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
4a15ea86
Commit
4a15ea86
authored
Mar 21, 2013
by
Edward Thomson
Committed by
Russell Belfer
Mar 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't convert CRLF to CRCRLF
parent
1098cfae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
src/crlf.c
+7
-2
tests-clar/checkout/crlf.c
+44
-0
No files found.
src/crlf.c
View file @
4a15ea86
...
@@ -224,11 +224,16 @@ static int convert_line_endings(git_buf *dest, const git_buf *source, const char
...
@@ -224,11 +224,16 @@ static int convert_line_endings(git_buf *dest, const git_buf *source, const char
{
{
const
char
*
scan
=
git_buf_cstr
(
source
),
const
char
*
scan
=
git_buf_cstr
(
source
),
*
next
,
*
next
,
*
line_end
,
*
scan_end
=
git_buf_cstr
(
source
)
+
git_buf_len
(
source
);
*
scan_end
=
git_buf_cstr
(
source
)
+
git_buf_len
(
source
);
while
((
next
=
memchr
(
scan
,
'\n'
,
scan_end
-
scan
))
!=
NULL
)
{
while
((
next
=
memchr
(
scan
,
'\n'
,
scan_end
-
scan
))
!=
NULL
)
{
if
(
next
>
scan
)
if
(
next
>
scan
)
{
git_buf_put
(
dest
,
scan
,
next
-
scan
);
line_end
=
*
(
next
-
1
)
==
'\r'
?
next
-
1
:
next
;
git_buf_put
(
dest
,
scan
,
line_end
-
scan
);
scan
=
next
+
1
;
}
git_buf_puts
(
dest
,
ending
);
git_buf_puts
(
dest
,
ending
);
scan
=
next
+
1
;
scan
=
next
+
1
;
}
}
...
...
tests-clar/checkout/crlf.c
View file @
4a15ea86
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
#define MORE_LF_TEXT_RAW "lf\nlf\ncrlf\r\nlf\nlf\n"
#define MORE_LF_TEXT_RAW "lf\nlf\ncrlf\r\nlf\nlf\n"
#define ALL_LF_TEXT_AS_CRLF "lf\r\nlf\r\nlf\r\nlf\r\nlf\r\n"
#define ALL_LF_TEXT_AS_CRLF "lf\r\nlf\r\nlf\r\nlf\r\nlf\r\n"
#define MORE_CRLF_TEXT_AS_CRLF "crlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf\r\n"
#define MORE_LF_TEXT_AS_CRLF "lf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\n"
static
git_repository
*
g_repo
;
static
git_repository
*
g_repo
;
...
@@ -78,6 +80,48 @@ void test_checkout_crlf__detect_crlf_autocrlf_true(void)
...
@@ -78,6 +80,48 @@ void test_checkout_crlf__detect_crlf_autocrlf_true(void)
#endif
#endif
}
}
void
test_checkout_crlf__more_lf_autocrlf_true
(
void
)
{
#ifdef GIT_WIN32
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE_CREATE
;
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
true
);
git_checkout_head
(
g_repo
,
&
opts
);
test_file_contents
(
"./crlf/more-lf"
,
MORE_LF_TEXT_AS_CRLF
);
#endif
}
void
test_checkout_crlf__more_crlf_autocrlf_true
(
void
)
{
#ifdef GIT_WIN32
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE_CREATE
;
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
true
);
git_checkout_head
(
g_repo
,
&
opts
);
test_file_contents
(
"./crlf/more-crlf"
,
MORE_CRLF_TEXT_AS_CRLF
);
#endif
}
void
test_checkout_crlf__all_crlf_autocrlf_true
(
void
)
{
#ifdef GIT_WIN32
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE_CREATE
;
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
true
);
git_checkout_head
(
g_repo
,
&
opts
);
test_file_contents
(
"./crlf/all-crlf"
,
ALL_CRLF_TEXT_RAW
);
#endif
}
void
test_checkout_crlf__autocrlf_true_index_size_is_filtered_size
(
void
)
void
test_checkout_crlf__autocrlf_true_index_size_is_filtered_size
(
void
)
{
{
#ifdef GIT_WIN32
#ifdef GIT_WIN32
...
...
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