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:
authorBen Straub <bstraub@github.com>2012-07-10 07:21:22 +0400
committerBen Straub <bstraub@github.com>2012-07-10 07:21:22 +0400
commitf2d42eea34b0b080877d3bfd5cd3dd3242459d32 (patch)
tree30e22b64d2fdb9cf74e0e5bf1537a59871ba31bb /src/crlf.c
parent4a26ee4fd4f389322017aa600b337544f46dfc8d (diff)
Checkout: add structure for CRLF.
Diffstat (limited to 'src/crlf.c')
-rw-r--r--src/crlf.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/crlf.c b/src/crlf.c
index 303a46d3b..888d86c36 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -184,7 +184,8 @@ static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *sou
return drop_crlf(dest, source);
}
-int git_filter_add__crlf_to_odb(git_vector *filters, git_repository *repo, const char *path)
+static int find_and_add_filter(git_vector *filters, git_repository *repo, const char *path,
+ int (*apply)(struct git_filter *self, git_buf *dest, const git_buf *source))
{
struct crlf_attrs ca;
struct crlf_filter *filter;
@@ -219,10 +220,25 @@ int git_filter_add__crlf_to_odb(git_vector *filters, git_repository *repo, const
filter = git__malloc(sizeof(struct crlf_filter));
GITERR_CHECK_ALLOC(filter);
- filter->f.apply = &crlf_apply_to_odb;
+ filter->f.apply = apply;
filter->f.do_free = NULL;
memcpy(&filter->attrs, &ca, sizeof(struct crlf_attrs));
return git_vector_insert(filters, filter);
}
+static int crlf_apply_to_workdir(git_filter *self, git_buf *dest, const git_buf *source)
+{
+ /* TODO */
+ return 0;
+}
+
+int git_filter_add__crlf_to_odb(git_vector *filters, git_repository *repo, const char *path)
+{
+ return find_and_add_filter(filters, repo, path, &crlf_apply_to_odb);
+}
+
+int git_filter_add__crlf_to_workdir(git_vector *filters, git_repository *repo, const char *path)
+{
+ return find_and_add_filter(filters, repo, path, &crlf_apply_to_workdir);
+}