git/convert.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
#include "convert.h"
#include "copy.h"
#include "gettext.h"
#include "hex.h"
#include "object-store-ll.h"
#include "attr.h"
#include "run-command.h"
#include "quote.h"
#include "read-cache-ll.h"
#include "sigchain.h"
#include "pkt-line.h"
#include "sub-process.h"
#include "trace.h"
#include "utf8.h"
#include "merge-ll.h"

/*
 * convert.c - convert a file when checking it out and checking it in.
 *
 * This should use the pathname to decide on whether it wants to do some
 * more interesting conversions (automatic gzip/unzip, general format
 * conversions etc etc), but by default it just does automatic CRLF<->LF
 * translation when the "text" attribute or "auto_crlf" option is set.
 */

/* Stat bits: When BIN is set, the txt bits are unset */
#define CONVERT_STAT_BITS_TXT_LF
#define CONVERT_STAT_BITS_TXT_CRLF
#define CONVERT_STAT_BITS_BIN

struct text_stat {};

static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)
{}

/*
 * The same heuristics as diff.c::mmfile_is_binary()
 * We treat files with bare CR as binary
 */
static int convert_is_binary(const struct text_stat *stats)
{}

static unsigned int gather_convert_stats(const char *data, unsigned long size)
{}

static const char *gather_convert_stats_ascii(const char *data, unsigned long size)
{}

const char *get_cached_convert_stats_ascii(struct index_state *istate,
					   const char *path)
{}

const char *get_wt_convert_stats_ascii(const char *path)
{}

static int text_eol_is_crlf(void)
{}

static enum eol output_eol(enum convert_crlf_action crlf_action)
{}

static void check_global_conv_flags_eol(const char *path,
			    struct text_stat *old_stats, struct text_stat *new_stats,
			    int conv_flags)
{}

static int has_crlf_in_index(struct index_state *istate, const char *path)
{}

static int will_convert_lf_to_crlf(struct text_stat *stats,
				   enum convert_crlf_action crlf_action)
{}

static int validate_encoding(const char *path, const char *enc,
		      const char *data, size_t len, int die_on_error)
{}

static void trace_encoding(const char *context, const char *path,
			   const char *encoding, const char *buf, size_t len)
{}

static int check_roundtrip(const char *enc_name)
{}

static const char *default_encoding =;

static int encode_to_git(const char *path, const char *src, size_t src_len,
			 struct strbuf *buf, const char *enc, int conv_flags)
{}

static int encode_to_worktree(const char *path, const char *src, size_t src_len,
			      struct strbuf *buf, const char *enc)
{}

static int crlf_to_git(struct index_state *istate,
		       const char *path, const char *src, size_t len,
		       struct strbuf *buf,
		       enum convert_crlf_action crlf_action, int conv_flags)
{}

static int crlf_to_worktree(const char *src, size_t len, struct strbuf *buf,
			    enum convert_crlf_action crlf_action)
{}

struct filter_params {};

static int filter_buffer_or_fd(int in UNUSED, int out, void *data)
{}

static int apply_single_file_filter(const char *path, const char *src, size_t len, int fd,
				    struct strbuf *dst, const char *cmd)
{}

#define CAP_CLEAN
#define CAP_SMUDGE
#define CAP_DELAY

struct cmd2process {};

static int subprocess_map_initialized;
static struct hashmap subprocess_map;

static int start_multi_file_filter_fn(struct subprocess_entry *subprocess)
{}

static void handle_filter_error(const struct strbuf *filter_status,
				struct cmd2process *entry,
				const unsigned int wanted_capability)
{}

static int apply_multi_file_filter(const char *path, const char *src, size_t len,
				   int fd, struct strbuf *dst, const char *cmd,
				   const unsigned int wanted_capability,
				   const struct checkout_metadata *meta,
				   struct delayed_checkout *dco)
{}


int async_query_available_blobs(const char *cmd, struct string_list *available_paths)
{}

static struct convert_driver {} *user_convert, **user_convert_tail;

static int apply_filter(const char *path, const char *src, size_t len,
			int fd, struct strbuf *dst, struct convert_driver *drv,
			const unsigned int wanted_capability,
			const struct checkout_metadata *meta,
			struct delayed_checkout *dco)
{}

static int read_convert_config(const char *var, const char *value,
			       const struct config_context *ctx UNUSED,
			       void *cb UNUSED)
{}

static int count_ident(const char *cp, unsigned long size)
{}

static int ident_to_git(const char *src, size_t len,
			struct strbuf *buf, int ident)
{}

static int ident_to_worktree(const char *src, size_t len,
			     struct strbuf *buf, int ident)
{}

static const char *git_path_check_encoding(struct attr_check_item *check)
{}

static enum convert_crlf_action git_path_check_crlf(struct attr_check_item *check)
{}

static enum eol git_path_check_eol(struct attr_check_item *check)
{}

static struct convert_driver *git_path_check_convert(struct attr_check_item *check)
{}

static int git_path_check_ident(struct attr_check_item *check)
{}

static struct attr_check *check;

void convert_attrs(struct index_state *istate,
		   struct conv_attrs *ca, const char *path)
{}

void reset_parsed_attributes(void)
{}

int would_convert_to_git_filter_fd(struct index_state *istate, const char *path)
{}

const char *get_convert_attr_ascii(struct index_state *istate, const char *path)
{}

int convert_to_git(struct index_state *istate,
		   const char *path, const char *src, size_t len,
		   struct strbuf *dst, int conv_flags)
{}

void convert_to_git_filter_fd(struct index_state *istate,
			      const char *path, int fd, struct strbuf *dst,
			      int conv_flags)
{}

static int convert_to_working_tree_ca_internal(const struct conv_attrs *ca,
					       const char *path, const char *src,
					       size_t len, struct strbuf *dst,
					       int normalizing,
					       const struct checkout_metadata *meta,
					       struct delayed_checkout *dco)
{}

int async_convert_to_working_tree_ca(const struct conv_attrs *ca,
				     const char *path, const char *src,
				     size_t len, struct strbuf *dst,
				     const struct checkout_metadata *meta,
				     void *dco)
{}

int convert_to_working_tree_ca(const struct conv_attrs *ca,
			       const char *path, const char *src,
			       size_t len, struct strbuf *dst,
			       const struct checkout_metadata *meta)
{}

int renormalize_buffer(struct index_state *istate, const char *path,
		       const char *src, size_t len, struct strbuf *dst)
{}

/*****************************************************************
 *
 * Streaming conversion support
 *
 *****************************************************************/

filter_fn;
free_fn;

struct stream_filter_vtbl {};

struct stream_filter {};

static int null_filter_fn(struct stream_filter *filter UNUSED,
			  const char *input, size_t *isize_p,
			  char *output, size_t *osize_p)
{}

static void null_free_fn(struct stream_filter *filter UNUSED)
{}

static struct stream_filter_vtbl null_vtbl =;

static struct stream_filter null_filter_singleton =;

int is_null_stream_filter(struct stream_filter *filter)
{}


/*
 * LF-to-CRLF filter
 */

struct lf_to_crlf_filter {};

static int lf_to_crlf_filter_fn(struct stream_filter *filter,
				const char *input, size_t *isize_p,
				char *output, size_t *osize_p)
{}

static void lf_to_crlf_free_fn(struct stream_filter *filter)
{}

static struct stream_filter_vtbl lf_to_crlf_vtbl =;

static struct stream_filter *lf_to_crlf_filter(void)
{}

/*
 * Cascade filter
 */
#define FILTER_BUFFER
struct cascade_filter {};

static int cascade_filter_fn(struct stream_filter *filter,
			     const char *input, size_t *isize_p,
			     char *output, size_t *osize_p)
{}

static void cascade_free_fn(struct stream_filter *filter)
{}

static struct stream_filter_vtbl cascade_vtbl =;

static struct stream_filter *cascade_filter(struct stream_filter *one,
					    struct stream_filter *two)
{}

/*
 * ident filter
 */
#define IDENT_DRAINING
#define IDENT_SKIPPING
struct ident_filter {};

static int is_foreign_ident(const char *str)
{}

static void ident_drain(struct ident_filter *ident, char **output_p, size_t *osize_p)
{}

static int ident_filter_fn(struct stream_filter *filter,
			   const char *input, size_t *isize_p,
			   char *output, size_t *osize_p)
{}

static void ident_free_fn(struct stream_filter *filter)
{}

static struct stream_filter_vtbl ident_vtbl =;

static struct stream_filter *ident_filter(const struct object_id *oid)
{}

/*
 * Return an appropriately constructed filter for the given ca, or NULL if
 * the contents cannot be filtered without reading the whole thing
 * in-core.
 *
 * Note that you would be crazy to set CRLF, smudge/clean or ident to a
 * large binary blob you would want us not to slurp into the memory!
 */
struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
					   const struct object_id *oid)
{}

struct stream_filter *get_stream_filter(struct index_state *istate,
					const char *path,
					const struct object_id *oid)
{}

void free_stream_filter(struct stream_filter *filter)
{}

int stream_filter(struct stream_filter *filter,
		  const char *input, size_t *isize_p,
		  char *output, size_t *osize_p)
{}

void init_checkout_metadata(struct checkout_metadata *meta, const char *refname,
			    const struct object_id *treeish,
			    const struct object_id *blob)
{}

void clone_checkout_metadata(struct checkout_metadata *dst,
			     const struct checkout_metadata *src,
			     const struct object_id *blob)
{}

enum conv_attrs_classification classify_conv_attrs(const struct conv_attrs *ca)
{}