]> git.proxmox.com Git - libgit2.git/blob - src/filter.h
filter: Load attributes for file
[libgit2.git] / src / filter.h
1 /*
2 * Copyright (C) 2009-2012 the libgit2 contributors
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_filter_h__
8 #define INCLUDE_filter_h__
9
10 #include "common.h"
11 #include "buffer.h"
12 #include "git2/odb.h"
13 #include "git2/repository.h"
14
15 typedef int (*git_filter_cb)(git_buf *dest, const git_buf *source, const char *filename);
16
17 typedef enum {
18 GIT_FILTER_TO_WORKTREE,
19 GIT_FILTER_TO_ODB
20 } git_filter_mode;
21
22 typedef enum {
23 GIT_CRLF_GUESS = -1,
24 GIT_CRLF_BINARY = 0,
25 GIT_CRLF_TEXT,
26 GIT_CRLF_INPUT,
27 GIT_CRLF_CRLF,
28 GIT_CRLF_AUTO,
29
30 GIT_SAFE_CRLF_FALSE = 0,
31 GIT_SAFE_CRLF_FAIL = 1,
32 GIT_SAFE_CRLF_WARN = 2,
33
34 GIT_AUTO_CRLF_FALSE = 0,
35 GIT_AUTO_CRLF_TRUE = 1,
36 GIT_AUTO_CRLF_INPUT = -1,
37 } git_crlf_t;
38
39 typedef enum {
40 GIT_EOL_UNSET,
41 GIT_EOL_CRLF,
42 GIT_EOL_LF,
43 #ifdef GIT_WIN32
44 GIT_EOL_NATIVE = GIT_EOL_CRLF
45 #else
46 GIT_EOL_NATIVE = GIT_EOL_LF
47 #endif
48 } git_eol_t;
49
50
51 typedef struct {
52 int crlf_action;
53 int eol_attr;
54 int ident;
55 } git_conv_attrs;
56
57 typedef struct {
58 /* NUL, CR, LF and CRLF counts */
59 unsigned int nul, cr, lf, crlf;
60
61 /* These are just approximations! */
62 unsigned int printable, nonprintable;
63 } git_text_stats;
64
65 extern int git_filter__load_for_file(git_vector *filters, git_repository *repo, const char *full_path, int mode);
66 extern int git_filter__load_attrs(git_conv_attrs *ca, git_repository *repo, const char *path);
67 extern int git_filter__apply(git_buf *dest, git_buf *source, git_vector *filters, const char *filename);
68
69 /* Gather stats for a piece of text */
70 extern void git_text__stat(git_text_stats *stats, git_buf *text);
71
72 /* Heuristics on a set of text stats to check whether it's binary
73 * text or not */
74 extern int git_text__is_binary(git_text_stats *stats);
75
76 #endif