Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-03-22 01:02:25 +0400
committerRussell Belfer <rb@github.com>2013-03-26 01:03:16 +0400
commit4a15ea869ca097dca0b45b1202429cc12cb94219 (patch)
treecc85fd20d1b762643d27d9343c82356ffd361099 /src/crlf.c
parent1098cfaecae823ede02881f995f18aee2908b89f (diff)
don't convert CRLF to CRCRLF
Diffstat (limited to 'src/crlf.c')
-rw-r--r--src/crlf.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/crlf.c b/src/crlf.c
index 84347ac6c..cd6d9825f 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -223,12 +223,17 @@ static int crlf_apply_to_odb(
static int convert_line_endings(git_buf *dest, const git_buf *source, const char *ending)
{
const char *scan = git_buf_cstr(source),
- *next,
- *scan_end = git_buf_cstr(source) + git_buf_len(source);
+ *next,
+ *line_end,
+ *scan_end = git_buf_cstr(source) + git_buf_len(source);
while ((next = memchr(scan, '\n', scan_end - scan)) != NULL) {
- if (next > scan)
- git_buf_put(dest, scan, next-scan);
+ if (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);
scan = next + 1;
}