vendor/libgit2/src/crlf.c in rugged-1.1.1 vs vendor/libgit2/src/crlf.c in rugged-1.2.0
- old
+ new
@@ -13,11 +13,10 @@
#include "git2/sys/filter.h"
#include "futils.h"
#include "hash.h"
#include "filter.h"
-#include "buf_text.h"
#include "repository.h"
typedef enum {
GIT_CRLF_UNDEFINED,
GIT_CRLF_BINARY,
@@ -217,11 +216,11 @@
/* Binary attribute? Empty file? Nothing to do */
if (ca->crlf_action == GIT_CRLF_BINARY || !git_buf_len(from))
return GIT_PASSTHROUGH;
- is_binary = git_buf_text_gather_stats(&stats, from, false);
+ is_binary = git_buf_gather_text_stats(&stats, from, false);
/* Heuristics to see if we can skip the conversion.
* Straight from Core Git.
*/
if (ca->crlf_action == GIT_CRLF_AUTO ||
@@ -245,11 +244,11 @@
/* If there are no CR characters to filter out, then just pass */
if (!stats.crlf)
return GIT_PASSTHROUGH;
/* Actually drop the carriage returns */
- return git_buf_text_crlf_to_lf(to, from);
+ return git_buf_crlf_to_lf(to, from);
}
static int crlf_apply_to_workdir(
struct crlf_attrs *ca,
git_buf *to,
@@ -260,11 +259,11 @@
/* Empty file? Nothing to do. */
if (git_buf_len(from) == 0 || output_eol(ca) != GIT_EOL_CRLF)
return GIT_PASSTHROUGH;
- is_binary = git_buf_text_gather_stats(&stats, from, false);
+ is_binary = git_buf_gather_text_stats(&stats, from, false);
/* If there are no LFs, or all LFs are part of a CRLF, nothing to do */
if (stats.lf == 0 || stats.lf == stats.crlf)
return GIT_PASSTHROUGH;
@@ -279,11 +278,11 @@
/* Don't filter binary files */
if (is_binary)
return GIT_PASSTHROUGH;
}
- return git_buf_text_lf_to_crlf(to, from);
+ return git_buf_lf_to_crlf(to, from);
}
static int convert_attrs(
struct crlf_attrs *ca,
const char **attr_values,
@@ -385,10 +384,21 @@
return crlf_apply_to_workdir(*payload, to, from);
else
return crlf_apply_to_odb(*payload, to, from, src);
}
+static int crlf_stream(
+ git_writestream **out,
+ git_filter *self,
+ void **payload,
+ const git_filter_source *src,
+ git_writestream *next)
+{
+ return git_filter_buffered_stream_new(out,
+ self, crlf_apply, NULL, payload, src, next);
+}
+
static void crlf_cleanup(
git_filter *self,
void *payload)
{
GIT_UNUSED(self);
@@ -404,10 +414,10 @@
f->f.version = GIT_FILTER_VERSION;
f->f.attributes = "crlf eol text";
f->f.initialize = NULL;
f->f.shutdown = git_filter_free;
f->f.check = crlf_check;
- f->f.apply = crlf_apply;
+ f->f.stream = crlf_stream;
f->f.cleanup = crlf_cleanup;
return (git_filter *)f;
}