Commit 4a15ea86 by Edward Thomson Committed by Russell Belfer

don't convert CRLF to CRCRLF

parent 1098cfae
...@@ -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;
} }
......
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment