diff options
author | Russell Belfer <rb@github.com> | 2013-09-24 10:11:20 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-09-24 10:11:20 -0700 |
commit | 634f10f69090b325a50c8bca6cb303397576305e (patch) | |
tree | 7728cd252fd6377749b593654d88d89270a66a73 /tests-clar/clar_libgit2.c | |
parent | a3c2d916d8ad67196d2211b0a88dcbab7a433764 (diff) | |
download | libgit2-634f10f69090b325a50c8bca6cb303397576305e.tar.gz |
Fix incorrect return code in crlf filter
The git_buf_text_gather_stats call returns a boolean indicating if
the file looks like binary data. That shouldn't be an error; it
should be used to skip CRLF processing though.
Diffstat (limited to 'tests-clar/clar_libgit2.c')
-rw-r--r-- | tests-clar/clar_libgit2.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests-clar/clar_libgit2.c b/tests-clar/clar_libgit2.c index d7e28831f..555af38db 100644 --- a/tests-clar/clar_libgit2.c +++ b/tests-clar/clar_libgit2.c @@ -30,24 +30,26 @@ void cl_git_mkfile(const char *filename, const char *content) } void cl_git_write2file( - const char *filename, const char *new_content, int flags, unsigned int mode) + const char *path, const char *content, size_t content_len, + int flags, unsigned int mode) { - int fd = p_open(filename, flags, mode); - cl_assert(fd >= 0); - if (!new_content) - new_content = "\n"; - cl_must_pass(p_write(fd, new_content, strlen(new_content))); + int fd; + cl_assert(path && content); + cl_assert((fd = p_open(path, flags, mode)) >= 0); + if (!content_len) + content_len = strlen(content); + cl_must_pass(p_write(fd, content, content_len)); cl_must_pass(p_close(fd)); } -void cl_git_append2file(const char *filename, const char *new_content) +void cl_git_append2file(const char *path, const char *content) { - cl_git_write2file(filename, new_content, O_WRONLY | O_CREAT | O_APPEND, 0644); + cl_git_write2file(path, content, 0, O_WRONLY | O_CREAT | O_APPEND, 0644); } -void cl_git_rewritefile(const char *filename, const char *new_content) +void cl_git_rewritefile(const char *path, const char *content) { - cl_git_write2file(filename, new_content, O_WRONLY | O_CREAT | O_TRUNC, 0644); + cl_git_write2file(path, content, 0, O_WRONLY | O_CREAT | O_TRUNC, 0644); } #ifdef GIT_WIN32 |