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:
authorRussell Belfer <rb@github.com>2013-09-12 01:23:39 +0400
committerRussell Belfer <rb@github.com>2013-09-17 20:31:45 +0400
commit40cb40fab93281c808255d980bbe81a18a4d9e9a (patch)
tree349cfd168a3a704288a3222f69374064e7d86c91 /src/crlf.c
parent0646634e2fea3e0adf724e0b7b15118574b589fc (diff)
Add functions to manipulate filter lists
Extend the git2/sys/filter API with functions to look up a filter and add it manually to a filter list. This requires some trickery because the regular attribute lookups and checks are bypassed when this happens, but in the right hands, it will allow a user to have granular control over applying filters.
Diffstat (limited to 'src/crlf.c')
-rw-r--r--src/crlf.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/crlf.c b/src/crlf.c
index e974208a6..99c154f70 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -86,6 +86,9 @@ static int has_cr_in_index(const git_filter_source *src)
git_off_t blobsize;
bool found_cr;
+ if (!path)
+ return false;
+
if (git_repository_index__weakptr(&index, repo) < 0) {
giterr_clear();
return false;
@@ -189,9 +192,7 @@ static const char *line_ending(struct crlf_attrs *ca)
switch (ca->eol) {
case GIT_EOL_UNSET:
- return GIT_EOL_NATIVE == GIT_EOL_CRLF
- ? "\r\n"
- : "\n";
+ return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n";
case GIT_EOL_CRLF:
return "\r\n";
@@ -302,7 +303,12 @@ static int crlf_apply(
const git_buffer *from,
const git_filter_source *src)
{
- GIT_UNUSED(self);
+ /* initialize payload in case `check` was bypassed */
+ if (!*payload) {
+ int error = crlf_check(self, payload, src, NULL);
+ if (error < 0 && error != GIT_ENOTFOUND)
+ return error;
+ }
if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
return crlf_apply_to_workdir(*payload, to, from);