ci: avoid pounding on the poor ci-artifacts container
[git/debian.git] / convert.h
blobe29d1026a6866b63b047b6838727bcb71ea6eccb
1 /*
2 * Copyright (c) 2011, Google Inc.
3 */
4 #ifndef CONVERT_H
5 #define CONVERT_H
7 #include "hash.h"
8 #include "string-list.h"
10 struct index_state;
11 struct strbuf;
13 #define CONV_EOL_RNDTRP_DIE (1<<0) /* Die if CRLF to LF to CRLF is different */
14 #define CONV_EOL_RNDTRP_WARN (1<<1) /* Warn if CRLF to LF to CRLF is different */
15 #define CONV_EOL_RENORMALIZE (1<<2) /* Convert CRLF to LF */
16 #define CONV_EOL_KEEP_CRLF (1<<3) /* Keep CRLF line endings as is */
17 #define CONV_WRITE_OBJECT (1<<4) /* Content is written to the index */
19 extern int global_conv_flags_eol;
21 enum auto_crlf {
22 AUTO_CRLF_FALSE = 0,
23 AUTO_CRLF_TRUE = 1,
24 AUTO_CRLF_INPUT = -1
27 extern enum auto_crlf auto_crlf;
29 enum eol {
30 EOL_UNSET,
31 EOL_CRLF,
32 EOL_LF,
33 #ifdef NATIVE_CRLF
34 EOL_NATIVE = EOL_CRLF
35 #else
36 EOL_NATIVE = EOL_LF
37 #endif
40 enum ce_delay_state {
41 CE_NO_DELAY = 0,
42 CE_CAN_DELAY = 1,
43 CE_RETRY = 2
46 struct delayed_checkout {
48 * State of the currently processed cache entry. If the state is
49 * CE_CAN_DELAY, then the filter can delay the current cache entry.
50 * If the state is CE_RETRY, then this signals the filter that the
51 * cache entry was requested before.
53 enum ce_delay_state state;
54 /* List of filter drivers that signaled delayed blobs. */
55 struct string_list filters;
56 /* List of delayed blobs identified by their path. */
57 struct string_list paths;
60 struct checkout_metadata {
61 const char *refname;
62 struct object_id treeish;
63 struct object_id blob;
66 extern enum eol core_eol;
67 extern char *check_roundtrip_encoding;
68 const char *get_cached_convert_stats_ascii(const struct index_state *istate,
69 const char *path);
70 const char *get_wt_convert_stats_ascii(const char *path);
71 const char *get_convert_attr_ascii(const struct index_state *istate,
72 const char *path);
74 /* returns 1 if *dst was used */
75 int convert_to_git(const struct index_state *istate,
76 const char *path, const char *src, size_t len,
77 struct strbuf *dst, int conv_flags);
78 int convert_to_working_tree(const struct index_state *istate,
79 const char *path, const char *src,
80 size_t len, struct strbuf *dst,
81 const struct checkout_metadata *meta);
82 int async_convert_to_working_tree(const struct index_state *istate,
83 const char *path, const char *src,
84 size_t len, struct strbuf *dst,
85 const struct checkout_metadata *meta,
86 void *dco);
87 int async_query_available_blobs(const char *cmd,
88 struct string_list *available_paths);
89 int renormalize_buffer(const struct index_state *istate,
90 const char *path, const char *src, size_t len,
91 struct strbuf *dst);
92 static inline int would_convert_to_git(const struct index_state *istate,
93 const char *path)
95 return convert_to_git(istate, path, NULL, 0, NULL, 0);
97 /* Precondition: would_convert_to_git_filter_fd(path) == true */
98 void convert_to_git_filter_fd(const struct index_state *istate,
99 const char *path, int fd,
100 struct strbuf *dst,
101 int conv_flags);
102 int would_convert_to_git_filter_fd(const struct index_state *istate,
103 const char *path);
106 * Initialize the checkout metadata with the given values. Any argument may be
107 * NULL if it is not applicable. The treeish should be a commit if that is
108 * available, and a tree otherwise.
110 * The refname is not copied and must be valid for the lifetime of the struct.
111 * THe object IDs are copied.
113 void init_checkout_metadata(struct checkout_metadata *meta, const char *refname,
114 const struct object_id *treeish,
115 const struct object_id *blob);
117 /* Copy the metadata from src to dst, updating the blob. */
118 void clone_checkout_metadata(struct checkout_metadata *dst,
119 const struct checkout_metadata *src,
120 const struct object_id *blob);
123 * Reset the internal list of attributes used by convert_to_git and
124 * convert_to_working_tree.
126 void reset_parsed_attributes(void);
128 /*****************************************************************
130 * Streaming conversion support
132 *****************************************************************/
134 struct stream_filter; /* opaque */
136 struct stream_filter *get_stream_filter(const struct index_state *istate,
137 const char *path,
138 const struct object_id *);
139 void free_stream_filter(struct stream_filter *);
140 int is_null_stream_filter(struct stream_filter *);
143 * Use as much input up to *isize_p and fill output up to *osize_p;
144 * update isize_p and osize_p to indicate how much buffer space was
145 * consumed and filled. Return 0 on success, non-zero on error.
147 * Some filters may need to buffer the input and look-ahead inside it
148 * to decide what to output, and they may consume more than zero bytes
149 * of input and still not produce any output. After feeding all the
150 * input, pass NULL as input and keep calling this function, to let
151 * such filters know there is no more input coming and it is time for
152 * them to produce the remaining output based on the buffered input.
154 int stream_filter(struct stream_filter *,
155 const char *input, size_t *isize_p,
156 char *output, size_t *osize_p);
158 #endif /* CONVERT_H */