git/convert.h

/*
 * Copyright (c) 2011, Google Inc.
 */
#ifndef CONVERT_H
#define CONVERT_H

#include "hash.h"
#include "string-list.h"

struct index_state;
struct strbuf;

#define CONV_EOL_RNDTRP_DIE
#define CONV_EOL_RNDTRP_WARN
#define CONV_EOL_RENORMALIZE
#define CONV_EOL_KEEP_CRLF
#define CONV_WRITE_OBJECT

extern int global_conv_flags_eol;

enum auto_crlf {};

extern enum auto_crlf auto_crlf;

enum eol {};

enum ce_delay_state {};

struct delayed_checkout {};

struct checkout_metadata {};

enum convert_crlf_action {};

struct convert_driver;

struct conv_attrs {};

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

extern enum eol core_eol;
extern char *check_roundtrip_encoding;
const char *get_cached_convert_stats_ascii(struct index_state *istate,
					   const char *path);
const char *get_wt_convert_stats_ascii(const char *path);
const char *get_convert_attr_ascii(struct index_state *istate,
				   const char *path);

/* returns 1 if *dst was used */
int convert_to_git(struct index_state *istate,
		   const char *path, const char *src, size_t len,
		   struct strbuf *dst, int conv_flags);
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 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);
static inline int convert_to_working_tree(struct index_state *istate,
					  const char *path, const char *src,
					  size_t len, struct strbuf *dst,
					  const struct checkout_metadata *meta)
{}
static inline int async_convert_to_working_tree(struct index_state *istate,
						const char *path, const char *src,
						size_t len, struct strbuf *dst,
						const struct checkout_metadata *meta,
						void *dco)
{}
int async_query_available_blobs(const char *cmd,
				struct string_list *available_paths);
int renormalize_buffer(struct index_state *istate,
		       const char *path, const char *src, size_t len,
		       struct strbuf *dst);
static inline int would_convert_to_git(struct index_state *istate,
				       const char *path)
{}
/* Precondition: would_convert_to_git_filter_fd(path) == true */
void convert_to_git_filter_fd(struct index_state *istate,
			      const char *path, int fd,
			      struct strbuf *dst,
			      int conv_flags);
int would_convert_to_git_filter_fd(struct index_state *istate,
				   const char *path);

/*
 * Initialize the checkout metadata with the given values.  Any argument may be
 * NULL if it is not applicable.  The treeish should be a commit if that is
 * available, and a tree otherwise.
 *
 * The refname is not copied and must be valid for the lifetime of the struct.
 * THe object IDs are copied.
 */
void init_checkout_metadata(struct checkout_metadata *meta, const char *refname,
			    const struct object_id *treeish,
			    const struct object_id *blob);

/* Copy the metadata from src to dst, updating the blob. */
void clone_checkout_metadata(struct checkout_metadata *dst,
			     const struct checkout_metadata *src,
			     const struct object_id *blob);

/*
 * Reset the internal list of attributes used by convert_to_git and
 * convert_to_working_tree.
 */
void reset_parsed_attributes(void);

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

struct stream_filter; /* opaque */

struct stream_filter *get_stream_filter(struct index_state *istate,
					const char *path,
					const struct object_id *);
struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca,
					   const struct object_id *oid);
void free_stream_filter(struct stream_filter *);
int is_null_stream_filter(struct stream_filter *);

/*
 * Use as much input up to *isize_p and fill output up to *osize_p;
 * update isize_p and osize_p to indicate how much buffer space was
 * consumed and filled. Return 0 on success, non-zero on error.
 *
 * Some filters may need to buffer the input and look-ahead inside it
 * to decide what to output, and they may consume more than zero bytes
 * of input and still not produce any output. After feeding all the
 * input, pass NULL as input and keep calling this function, to let
 * such filters know there is no more input coming and it is time for
 * them to produce the remaining output based on the buffered input.
 */
int stream_filter(struct stream_filter *,
		  const char *input, size_t *isize_p,
		  char *output, size_t *osize_p);

enum conv_attrs_classification {};

enum conv_attrs_classification classify_conv_attrs(
	const struct conv_attrs *ca);

#endif /* CONVERT_H */