diff options
author | Russell Belfer <rb@github.com> | 2012-11-28 09:58:48 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-11-28 09:58:48 -0800 |
commit | 7bf87ab6987cf6b9e166e23d2d9dbdcd2511fb32 (patch) | |
tree | dcc8a92ce69b2a0d9d8cca98d67f0cc71177ce40 /src/crlf.c | |
parent | 693021262ba0eeac2923bbce1b2262717019c807 (diff) | |
download | libgit2-7bf87ab6987cf6b9e166e23d2d9dbdcd2511fb32.tar.gz |
Consolidate text buffer functions
There are many scattered functions that look into the contents of
buffers to do various text manipulations (such as escaping or
unescaping data, calculating text stats, guessing if content is
binary, etc). This groups all those functions together into a
new file and converts the code to use that.
This has two enhancements to existing functionality. The old
text stats function is significantly rewritten and the BOM
detection code was extended (although largely we can't deal with
anything other than a UTF8 BOM).
Diffstat (limited to 'src/crlf.c')
-rw-r--r-- | src/crlf.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/crlf.c b/src/crlf.c index 5e86b4eb6..80204ebf0 100644 --- a/src/crlf.c +++ b/src/crlf.c @@ -148,8 +148,11 @@ static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *sou if (filter->attrs.crlf_action == GIT_CRLF_AUTO || filter->attrs.crlf_action == GIT_CRLF_GUESS) { - git_text_stats stats; - git_text_gather_stats(&stats, source); + git_buf_text_stats stats; + + /* Check heuristics for binary vs text... */ + if (git_buf_text_gather_stats(&stats, source, false)) + return -1; /* * We're currently not going to even try to convert stuff @@ -159,12 +162,6 @@ static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *sou if (stats.cr != stats.crlf) return -1; - /* - * And add some heuristics for binary vs text, of course... - */ - if (git_text_is_binary(&stats)) - return -1; - #if 0 if (crlf_action == CRLF_GUESS) { /* |