git/diff.c

/*
 * Copyright (C) 2005 Junio C Hamano
 */

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "abspath.h"
#include "base85.h"
#include "config.h"
#include "convert.h"
#include "environment.h"
#include "gettext.h"
#include "tempfile.h"
#include "revision.h"
#include "quote.h"
#include "diff.h"
#include "diffcore.h"
#include "delta.h"
#include "hex.h"
#include "xdiff-interface.h"
#include "color.h"
#include "run-command.h"
#include "utf8.h"
#include "object-store-ll.h"
#include "userdiff.h"
#include "submodule.h"
#include "hashmap.h"
#include "mem-pool.h"
#include "merge-ll.h"
#include "string-list.h"
#include "strvec.h"
#include "tmp-objdir.h"
#include "graph.h"
#include "oid-array.h"
#include "packfile.h"
#include "pager.h"
#include "parse-options.h"
#include "help.h"
#include "promisor-remote.h"
#include "dir.h"
#include "object-file.h"
#include "object-name.h"
#include "read-cache-ll.h"
#include "setup.h"
#include "strmap.h"
#include "ws.h"

#ifdef NO_FAST_WORKING_DIRECTORY
#define FAST_WORKING_DIRECTORY
#else
#define FAST_WORKING_DIRECTORY
#endif

static int diff_detect_rename_default;
static int diff_indent_heuristic =;
static int diff_rename_limit_default =;
static int diff_suppress_blank_empty;
static int diff_use_color_default =;
static int diff_color_moved_default;
static int diff_color_moved_ws_default;
static int diff_context_default =;
static int diff_interhunk_context_default;
static char *diff_word_regex_cfg;
static struct external_diff external_diff_cfg;
static char *diff_order_file_cfg;
int diff_auto_refresh_index =;
static int diff_mnemonic_prefix;
static int diff_no_prefix;
static char *diff_src_prefix;
static char *diff_dst_prefix;
static int diff_relative;
static int diff_stat_name_width;
static int diff_stat_graph_width;
static int diff_dirstat_permille_default =;
static struct diff_options default_diff_options;
static long diff_algorithm;
static unsigned ws_error_highlight_default =;

static char diff_colors[][COLOR_MAXLEN] =;

static const char *color_diff_slots[] =;

define_list_config_array_extra();

static int parse_diff_color_slot(const char *var)
{}

static int parse_dirstat_params(struct diff_options *options, const char *params_string,
				struct strbuf *errmsg)
{}

static int parse_submodule_params(struct diff_options *options, const char *value)
{}

int git_config_rename(const char *var, const char *value)
{}

long parse_algorithm_value(const char *value)
{}

static int parse_one_token(const char **arg, const char *token)
{}

static int parse_ws_error_highlight(const char *arg)
{}

/*
 * These are to give UI layer defaults.
 * The core-level commands such as git-diff-files should
 * never be affected by the setting of diff.renames
 * the user happens to have in the configuration file.
 */
void init_diff_ui_defaults(void)
{}

int git_diff_heuristic_config(const char *var, const char *value,
			      void *cb UNUSED)
{}

static int parse_color_moved(const char *arg)
{}

static unsigned parse_color_moved_ws(const char *arg)
{}

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

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

static char *quote_two(const char *one, const char *two)
{}

static const struct external_diff *external_diff(void)
{}

/*
 * Keep track of files used for diffing. Sometimes such an entry
 * refers to a temporary file, sometimes to an existing file, and
 * sometimes to "/dev/null".
 */
static struct diff_tempfile {} diff_temp[2];

struct emit_callback {};

static int count_lines(const char *data, int size)
{}

static int fill_mmfile(struct repository *r, mmfile_t *mf,
		       struct diff_filespec *one)
{}

/* like fill_mmfile, but only for size, so we can avoid retrieving blob */
static unsigned long diff_filespec_size(struct repository *r,
					struct diff_filespec *one)
{}

static int count_trailing_blank(mmfile_t *mf)
{}

static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2,
			       struct emit_callback *ecbdata)
{}

static void emit_line_0(struct diff_options *o,
			const char *set_sign, const char *set, unsigned reverse, const char *reset,
			int first, const char *line, int len)
{}

static void emit_line(struct diff_options *o, const char *set, const char *reset,
		      const char *line, int len)
{}

enum diff_symbol {};
/*
 * Flags for content lines:
 * 0..12 are whitespace rules
 * 13-15 are WSEH_NEW | WSEH_OLD | WSEH_CONTEXT
 * 16 is marking if the line is blank at EOF
 */
#define DIFF_SYMBOL_CONTENT_BLANK_LINE_EOF
#define DIFF_SYMBOL_MOVED_LINE
#define DIFF_SYMBOL_MOVED_LINE_ALT
#define DIFF_SYMBOL_MOVED_LINE_UNINTERESTING
#define DIFF_SYMBOL_CONTENT_WS_MASK

/*
 * This struct is used when we need to buffer the output of the diff output.
 *
 * NEEDSWORK: Instead of storing a copy of the line, add an offset pointer
 * into the pre/post image file. This pointer could be a union with the
 * line pointer. By storing an offset into the file instead of the literal line,
 * we can decrease the memory footprint for the buffered output. At first we
 * may want to only have indirection for the content lines, but we could also
 * enhance the state for emitting prefabricated lines, e.g. the similarity
 * score line or hunk/file headers would only need to store a number or path
 * and then the output can be constructed later on depending on state.
 */
struct emitted_diff_symbol {};
#define EMITTED_DIFF_SYMBOL_INIT

struct emitted_diff_symbols {};
#define EMITTED_DIFF_SYMBOLS_INIT

static void append_emitted_diff_symbol(struct diff_options *o,
				       struct emitted_diff_symbol *e)
{}

static void free_emitted_diff_symbols(struct emitted_diff_symbols *e)
{}

struct moved_entry {};

struct moved_block {};

#define INDENT_BLANKLINE

static void fill_es_indent_data(struct emitted_diff_symbol *es)
{}

static int compute_ws_delta(const struct emitted_diff_symbol *a,
			    const struct emitted_diff_symbol *b)
{}

static int cmp_in_block_with_wsd(const struct moved_entry *cur,
				 const struct emitted_diff_symbol *l,
				 struct moved_block *pmb)
{}

struct interned_diff_symbol {};

static int interned_diff_symbol_cmp(const void *hashmap_cmp_fn_data,
				    const struct hashmap_entry *eptr,
				    const struct hashmap_entry *entry_or_key,
				    const void *keydata UNUSED)
{}

static void prepare_entry(struct diff_options *o, struct emitted_diff_symbol *l,
			  struct interned_diff_symbol *s)
{}

struct moved_entry_list {};

static struct moved_entry_list *add_lines_to_move_detection(struct diff_options *o,
							    struct mem_pool *entry_mem_pool)
{}

static void pmb_advance_or_null(struct diff_options *o,
				struct emitted_diff_symbol *l,
				struct moved_block *pmb,
				int *pmb_nr)
{}

static void fill_potential_moved_blocks(struct diff_options *o,
					struct moved_entry *match,
					struct emitted_diff_symbol *l,
					struct moved_block **pmb_p,
					int *pmb_alloc_p, int *pmb_nr_p)

{}

/*
 * If o->color_moved is COLOR_MOVED_PLAIN, this function does nothing.
 *
 * Otherwise, if the last block has fewer alphanumeric characters than
 * COLOR_MOVED_MIN_ALNUM_COUNT, unset DIFF_SYMBOL_MOVED_LINE on all lines in
 * that block.
 *
 * The last block consists of the (n - block_length)'th line up to but not
 * including the nth line.
 *
 * Returns 0 if the last block is empty or is unset by this function, non zero
 * otherwise.
 *
 * NEEDSWORK: This uses the same heuristic as blame_entry_score() in blame.c.
 * Think of a way to unify them.
 */
#define DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK
static int adjust_last_block(struct diff_options *o, int n, int block_length)
{}

/* Find blocks of moved code, delegate actual coloring decision to helper */
static void mark_color_as_moved(struct diff_options *o,
				struct moved_entry_list *entry_list)
{}

static void dim_moved_lines(struct diff_options *o)
{}

static void emit_line_ws_markup(struct diff_options *o,
				const char *set_sign, const char *set,
				const char *reset,
				int sign_index, const char *line, int len,
				unsigned ws_rule, int blank_at_eof)
{}

static void emit_diff_symbol_from_struct(struct diff_options *o,
					 struct emitted_diff_symbol *eds)
{}

static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s,
			     const char *line, int len, unsigned flags)
{}

void diff_emit_submodule_del(struct diff_options *o, const char *line)
{}

void diff_emit_submodule_add(struct diff_options *o, const char *line)
{}

void diff_emit_submodule_untracked(struct diff_options *o, const char *path)
{}

void diff_emit_submodule_modified(struct diff_options *o, const char *path)
{}

void diff_emit_submodule_header(struct diff_options *o, const char *header)
{}

void diff_emit_submodule_error(struct diff_options *o, const char *err)
{}

void diff_emit_submodule_pipethrough(struct diff_options *o,
				     const char *line, int len)
{}

static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
{}

static void emit_add_line(struct emit_callback *ecbdata,
			  const char *line, int len)
{}

static void emit_del_line(struct emit_callback *ecbdata,
			  const char *line, int len)
{}

static void emit_context_line(struct emit_callback *ecbdata,
			      const char *line, int len)
{}

static void emit_hunk_header(struct emit_callback *ecbdata,
			     const char *line, int len)
{}

static struct diff_tempfile *claim_diff_tempfile(void)
{}

static void remove_tempfile(void)
{}

static void add_line_count(struct strbuf *out, int count)
{}

static void emit_rewrite_lines(struct emit_callback *ecb,
			       int prefix, const char *data, int size)
{}

static void emit_rewrite_diff(const char *name_a,
			      const char *name_b,
			      struct diff_filespec *one,
			      struct diff_filespec *two,
			      struct userdiff_driver *textconv_one,
			      struct userdiff_driver *textconv_two,
			      struct diff_options *o)
{}

struct diff_words_buffer {};

static void diff_words_append(char *line, unsigned long len,
		struct diff_words_buffer *buffer)
{}

struct diff_words_style_elem {};

struct diff_words_style {};

static struct diff_words_style diff_words_styles[] =;

struct diff_words_data {};

static int fn_out_diff_words_write_helper(struct diff_options *o,
					  struct diff_words_style_elem *st_el,
					  const char *newline,
					  size_t count, const char *buf)
{}

/*
 * '--color-words' algorithm can be described as:
 *
 *   1. collect the minus/plus lines of a diff hunk, divided into
 *      minus-lines and plus-lines;
 *
 *   2. break both minus-lines and plus-lines into words and
 *      place them into two mmfile_t with one word for each line;
 *
 *   3. use xdiff to run diff on the two mmfile_t to get the words level diff;
 *
 * And for the common parts of the both file, we output the plus side text.
 * diff_words->current_plus is used to trace the current position of the plus file
 * which printed. diff_words->last_minus is used to trace the last minus word
 * printed.
 *
 * For '--graph' to work with '--color-words', we need to output the graph prefix
 * on each line of color words output. Generally, there are two conditions on
 * which we should output the prefix.
 *
 *   1. diff_words->last_minus == 0 &&
 *      diff_words->current_plus == diff_words->plus.text.ptr
 *
 *      that is: the plus text must start as a new line, and if there is no minus
 *      word printed, a graph prefix must be printed.
 *
 *   2. diff_words->current_plus > diff_words->plus.text.ptr &&
 *      *(diff_words->current_plus - 1) == '\n'
 *
 *      that is: a graph prefix must be printed following a '\n'
 */
static int color_words_output_graph_prefix(struct diff_words_data *diff_words)
{}

static void fn_out_diff_words_aux(void *priv,
				  long minus_first, long minus_len,
				  long plus_first, long plus_len,
				  const char *func UNUSED, long funclen UNUSED)
{}

/* This function starts looking at *begin, and returns 0 iff a word was found. */
static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,
		int *begin, int *end)
{}

/*
 * This function splits the words in buffer->text, stores the list with
 * newline separator into out, and saves the offsets of the original words
 * in buffer->orig.
 */
static void diff_words_fill(struct diff_words_buffer *buffer, mmfile_t *out,
		regex_t *word_regex)
{}

/* this executes the word diff on the accumulated buffers */
static void diff_words_show(struct diff_words_data *diff_words)
{}

/* In "color-words" mode, show word-diff of words accumulated in the buffer */
static void diff_words_flush(struct emit_callback *ecbdata)
{}

static void diff_filespec_load_driver(struct diff_filespec *one,
				      struct index_state *istate)
{}

static const char *userdiff_word_regex(struct diff_filespec *one,
				       struct index_state *istate)
{}

static void init_diff_words_data(struct emit_callback *ecbdata,
				 struct diff_options *orig_opts,
				 struct diff_filespec *one,
				 struct diff_filespec *two)
{}

static void free_diff_words_data(struct emit_callback *ecbdata)
{}

const char *diff_get_color(int diff_use_color, enum color_diff ix)
{}

const char *diff_line_prefix(struct diff_options *opt)
{}

static unsigned long sane_truncate_line(char *line, unsigned long len)
{}

static void find_lno(const char *line, struct emit_callback *ecbdata)
{}

static int fn_out_consume(void *priv, char *line, unsigned long len)
{}

static void pprint_rename(struct strbuf *name, const char *a, const char *b)
{}

static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
					  const char *name_a,
					  const char *name_b)
{}

static int diffstat_consume(void *priv, char *line, unsigned long len)
{}

const char mime_boundary_leader[] =;

static int scale_linear(int it, int width, int max_change)
{}

static void show_graph(struct strbuf *out, char ch, int cnt,
		       const char *set, const char *reset)
{}

static void fill_print_name(struct diffstat_file *file)
{}

static void print_stat_summary_inserts_deletes(struct diff_options *options,
		int files, int insertions, int deletions)
{}

void print_stat_summary(FILE *fp, int files,
			int insertions, int deletions)
{}

static void show_stats(struct diffstat_t *data, struct diff_options *options)
{}

static void show_shortstats(struct diffstat_t *data, struct diff_options *options)
{}

static void show_numstat(struct diffstat_t *data, struct diff_options *options)
{}

struct dirstat_file {};

struct dirstat_dir {};

static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
		unsigned long changed, const char *base, int baselen)
{}

static int dirstat_compare(const void *_a, const void *_b)
{}

static void conclude_dirstat(struct diff_options *options,
			     struct dirstat_dir *dir,
			     unsigned long changed)
{}

static void show_dirstat(struct diff_options *options)
{}

static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *options)
{}

static void free_diffstat_file(struct diffstat_file *f)
{}

void free_diffstat_info(struct diffstat_t *diffstat)
{}

struct checkdiff_t {};

static int is_conflict_marker(const char *line, int marker_size, unsigned long len)
{}

static void checkdiff_consume_hunk(void *priv,
				   long ob UNUSED, long on UNUSED,
				   long nb, long nn UNUSED,
				   const char *func UNUSED, long funclen UNUSED)

{}

static int checkdiff_consume(void *priv, char *line, unsigned long len)
{}

static unsigned char *deflate_it(char *data,
				 unsigned long size,
				 unsigned long *result_size)
{}

static void emit_binary_diff_body(struct diff_options *o,
				  mmfile_t *one, mmfile_t *two)
{}

static void emit_binary_diff(struct diff_options *o,
			     mmfile_t *one, mmfile_t *two)
{}

int diff_filespec_is_binary(struct repository *r,
			    struct diff_filespec *one)
{}

static const struct userdiff_funcname *
diff_funcname_pattern(struct diff_options *o, struct diff_filespec *one)
{}

void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b)
{}

void diff_set_noprefix(struct diff_options *options)
{}

void diff_set_default_prefix(struct diff_options *options)
{}

struct userdiff_driver *get_textconv(struct repository *r,
				     struct diff_filespec *one)
{}

static struct string_list *additional_headers(struct diff_options *o,
					      const char *path)
{}

static void add_formatted_header(struct strbuf *msg,
				  const char *header,
				  const char *line_prefix,
				  const char *meta,
				  const char *reset)
{}

static void add_formatted_headers(struct strbuf *msg,
				  struct string_list *more_headers,
				  const char *line_prefix,
				  const char *meta,
				  const char *reset)
{}

static int diff_filepair_is_phoney(struct diff_filespec *one,
				   struct diff_filespec *two)
{}

static int set_diff_algorithm(struct diff_options *opts,
			      const char *alg)
{}

static void builtin_diff(const char *name_a,
			 const char *name_b,
			 struct diff_filespec *one,
			 struct diff_filespec *two,
			 const char *xfrm_msg,
			 int must_show_header,
			 struct diff_options *o,
			 int complete_rewrite)
{}

static const char *get_compact_summary(const struct diff_filepair *p, int is_renamed)
{}

static void builtin_diffstat(const char *name_a, const char *name_b,
			     struct diff_filespec *one,
			     struct diff_filespec *two,
			     struct diffstat_t *diffstat,
			     struct diff_options *o,
			     struct diff_filepair *p)
{}

static void builtin_checkdiff(const char *name_a, const char *name_b,
			      const char *attr_path,
			      struct diff_filespec *one,
			      struct diff_filespec *two,
			      struct diff_options *o)
{}

struct diff_filespec *alloc_filespec(const char *path)
{}

void free_filespec(struct diff_filespec *spec)
{}

void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
		   int oid_valid, unsigned short mode)
{}

/*
 * Given a name and sha1 pair, if the index tells us the file in
 * the work tree has that object contents, return true, so that
 * prepare_temp_file() does not have to inflate and extract.
 */
static int reuse_worktree_file(struct index_state *istate,
			       const char *name,
			       const struct object_id *oid,
			       int want_file)
{}

static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
{}

/*
 * While doing rename detection and pickaxe operation, we may need to
 * grab the data for the blob (or file) for our own in-core comparison.
 * diff_filespec has data and size fields for this purpose.
 */
int diff_populate_filespec(struct repository *r,
			   struct diff_filespec *s,
			   const struct diff_populate_filespec_options *options)
{}

void diff_free_filespec_blob(struct diff_filespec *s)
{}

void diff_free_filespec_data(struct diff_filespec *s)
{}

static void prep_temp_blob(struct index_state *istate,
			   const char *path, struct diff_tempfile *temp,
			   void *blob,
			   unsigned long size,
			   const struct object_id *oid,
			   int mode)
{}

static struct diff_tempfile *prepare_temp_file(struct repository *r,
					       struct diff_filespec *one)
{}

static void add_external_diff_name(struct repository *r,
				   struct strvec *argv,
				   struct diff_filespec *df)
{}

/* An external diff command takes:
 *
 * diff-cmd name infile1 infile1-sha1 infile1-mode \
 *               infile2 infile2-sha1 infile2-mode [ rename-to ]
 *
 */
static void run_external_diff(const struct external_diff *pgm,
			      const char *name,
			      const char *other,
			      struct diff_filespec *one,
			      struct diff_filespec *two,
			      const char *xfrm_msg,
			      struct diff_options *o)
{}

static int similarity_index(struct diff_filepair *p)
{}

static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
{}

static void fill_metainfo(struct strbuf *msg,
			  const char *name,
			  const char *other,
			  struct diff_filespec *one,
			  struct diff_filespec *two,
			  struct diff_options *o,
			  struct diff_filepair *p,
			  int *must_show_header,
			  int use_color)
{}

static void run_diff_cmd(const struct external_diff *pgm,
			 const char *name,
			 const char *other,
			 const char *attr_path,
			 struct diff_filespec *one,
			 struct diff_filespec *two,
			 struct strbuf *msg,
			 struct diff_options *o,
			 struct diff_filepair *p)
{}

static void diff_fill_oid_info(struct diff_filespec *one, struct index_state *istate)
{}

static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
{}

static void run_diff(struct diff_filepair *p, struct diff_options *o)
{}

static void run_diffstat(struct diff_filepair *p, struct diff_options *o,
			 struct diffstat_t *diffstat)
{}

static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
{}

void repo_diff_setup(struct repository *r, struct diff_options *options)
{}

static const char diff_status_letters[] =;

static unsigned int filter_bit['Z' + 1];

static void prepare_filter_bits(void)
{}

static unsigned filter_bit_tst(char status, const struct diff_options *opt)
{}

unsigned diff_filter_bit(char status)
{}

int diff_check_follow_pathspec(struct pathspec *ps, int die_on_error)
{}

void diff_setup_done(struct diff_options *options)
{}

int parse_long_opt(const char *opt, const char **argv,
		   const char **optarg)
{}

static int diff_opt_stat(const struct option *opt, const char *value, int unset)
{}

static int parse_dirstat_opt(struct diff_options *options, const char *params)
{}

static int diff_opt_diff_filter(const struct option *option,
				const char *optarg, int unset)
{}

static void enable_patch_output(int *fmt)
{}

static int diff_opt_ws_error_highlight(const struct option *option,
				       const char *arg, int unset)
{}

static int diff_opt_find_object(const struct option *option,
				const char *arg, int unset)
{}

static int diff_opt_anchored(const struct option *opt,
			     const char *arg, int unset)
{}

static int diff_opt_binary(const struct option *opt,
			   const char *arg, int unset)
{}

static int diff_opt_break_rewrites(const struct option *opt,
				   const char *arg, int unset)
{}

static int diff_opt_char(const struct option *opt,
			 const char *arg, int unset)
{}

static int diff_opt_color_moved(const struct option *opt,
				const char *arg, int unset)
{}

static int diff_opt_color_moved_ws(const struct option *opt,
				   const char *arg, int unset)
{}

static int diff_opt_color_words(const struct option *opt,
				const char *arg, int unset)
{}

static int diff_opt_compact_summary(const struct option *opt,
				    const char *arg, int unset)
{}

static int diff_opt_diff_algorithm(const struct option *opt,
				   const char *arg, int unset)
{}

static int diff_opt_diff_algorithm_no_arg(const struct option *opt,
				   const char *arg, int unset)
{}

static int diff_opt_dirstat(const struct option *opt,
			    const char *arg, int unset)
{}

static int diff_opt_find_copies(const struct option *opt,
				const char *arg, int unset)
{}

static int diff_opt_find_renames(const struct option *opt,
				 const char *arg, int unset)
{}

static int diff_opt_follow(const struct option *opt,
			   const char *arg, int unset)
{}

static int diff_opt_ignore_submodules(const struct option *opt,
				      const char *arg, int unset)
{}

static int diff_opt_line_prefix(const struct option *opt,
				const char *optarg, int unset)
{}

static int diff_opt_no_prefix(const struct option *opt,
			      const char *optarg, int unset)
{}

static int diff_opt_default_prefix(const struct option *opt,
				   const char *optarg, int unset)
{}

static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
					     const struct option *opt,
					     const char *arg, int unset)
{}

static int diff_opt_patience(const struct option *opt,
			     const char *arg, int unset)
{}

static int diff_opt_ignore_regex(const struct option *opt,
				 const char *arg, int unset)
{}

static int diff_opt_pickaxe_regex(const struct option *opt,
				  const char *arg, int unset)
{}

static int diff_opt_pickaxe_string(const struct option *opt,
				   const char *arg, int unset)
{}

static int diff_opt_relative(const struct option *opt,
			     const char *arg, int unset)
{}

static int diff_opt_submodule(const struct option *opt,
			      const char *arg, int unset)
{}

static int diff_opt_textconv(const struct option *opt,
			     const char *arg, int unset)
{}

static int diff_opt_unified(const struct option *opt,
			    const char *arg, int unset)
{}

static int diff_opt_word_diff(const struct option *opt,
			      const char *arg, int unset)
{}

static int diff_opt_word_diff_regex(const struct option *opt,
				    const char *arg, int unset)
{}

static int diff_opt_rotate_to(const struct option *opt, const char *arg, int unset)
{}

/*
 * Consider adding new flags to __git_diff_common_options
 * in contrib/completion/git-completion.bash
 */
struct option *add_diff_options(const struct option *opts,
				struct diff_options *options)
{}

int diff_opt_parse(struct diff_options *options,
		   const char **av, int ac, const char *prefix)
{}

int parse_rename_score(const char **cp_p)
{}

struct diff_queue_struct diff_queued_diff;

void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
{}

struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
				 struct diff_filespec *one,
				 struct diff_filespec *two)
{}

void diff_free_filepair(struct diff_filepair *p)
{}

void diff_queue_init(struct diff_queue_struct *q)
{}

void diff_queue_clear(struct diff_queue_struct *q)
{}

const char *diff_aligned_abbrev(const struct object_id *oid, int len)
{}

static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
{}

int diff_unmodified_pair(struct diff_filepair *p)
{}

static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
{}

static void diff_flush_stat(struct diff_filepair *p, struct diff_options *o,
			    struct diffstat_t *diffstat)
{}

static void diff_flush_checkdiff(struct diff_filepair *p,
		struct diff_options *o)
{}

int diff_queue_is_empty(struct diff_options *o)
{}

#if DIFF_DEBUG
void diff_debug_filespec(struct diff_filespec *s, int x, const char *one)
{
	fprintf(stderr, "queue[%d] %s (%s) %s %06o %s\n",
		x, one ? one : "",
		s->path,
		DIFF_FILE_VALID(s) ? "valid" : "invalid",
		s->mode,
		s->oid_valid ? oid_to_hex(&s->oid) : "");
	fprintf(stderr, "queue[%d] %s size %lu\n",
		x, one ? one : "",
		s->size);
}

void diff_debug_filepair(const struct diff_filepair *p, int i)
{
	diff_debug_filespec(p->one, i, "one");
	diff_debug_filespec(p->two, i, "two");
	fprintf(stderr, "score %d, status %c rename_used %d broken %d\n",
		p->score, p->status ? p->status : '?',
		p->one->rename_used, p->broken_pair);
}

void diff_debug_queue(const char *msg, struct diff_queue_struct *q)
{
	int i;
	if (msg)
		fprintf(stderr, "%s\n", msg);
	fprintf(stderr, "q->nr = %d\n", q->nr);
	for (i = 0; i < q->nr; i++) {
		struct diff_filepair *p = q->queue[i];
		diff_debug_filepair(p, i);
	}
}
#endif

static void diff_resolve_rename_copy(void)
{}

static int check_pair_status(struct diff_filepair *p)
{}

static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)
{}

static void show_file_mode_name(struct diff_options *opt, const char *newdelete, struct diff_filespec *fs)
{}

static void show_mode_change(struct diff_options *opt, struct diff_filepair *p,
		int show_name)
{}

static void show_rename_copy(struct diff_options *opt, const char *renamecopy,
		struct diff_filepair *p)
{}

static void diff_summary(struct diff_options *opt, struct diff_filepair *p)
{}

struct patch_id_t {};

static int remove_space(char *line, int len)
{}

void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx)
{}

static int patch_id_consume(void *priv, char *line, unsigned long len)
{}

static void patch_id_add_string(git_hash_ctx *ctx, const char *str)
{}

static void patch_id_add_mode(git_hash_ctx *ctx, unsigned mode)
{}

/* returns 0 upon success, and writes result into oid */
static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
{}

int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
{}

static int is_summary_empty(const struct diff_queue_struct *q)
{}

static const char rename_limit_warning[] =);

static const char degrade_cc_to_c_warning[] =);

static const char rename_limit_advice[] =);

void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc)
{}

static void create_filepairs_for_header_only_notifications(struct diff_options *o)
{}

static void diff_flush_patch_all_file_pairs(struct diff_options *o)
{}

static void diff_free_file(struct diff_options *options)
{}

static void diff_free_ignore_regex(struct diff_options *options)
{}

void diff_free(struct diff_options *options)
{}

void diff_flush(struct diff_options *options)
{}

static int match_filter(const struct diff_options *options, const struct diff_filepair *p)
{}

static void diffcore_apply_filter(struct diff_options *options)
{}

/* Check whether two filespecs with the same mode and size are identical */
static int diff_filespec_is_identical(struct repository *r,
				      struct diff_filespec *one,
				      struct diff_filespec *two)
{}

static int diff_filespec_check_stat_unmatch(struct repository *r,
					    struct diff_filepair *p)
{}

static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
{}

static int diffnamecmp(const void *a_, const void *b_)
{}

void diffcore_fix_diff_index(void)
{}

void diff_add_if_missing(struct repository *r,
			 struct oid_array *to_fetch,
			 const struct diff_filespec *filespec)
{}

void diff_queued_diff_prefetch(void *repository)
{}

void init_diffstat_widths(struct diff_options *options)
{}

void diffcore_std(struct diff_options *options)
{}

int diff_result_code(struct rev_info *revs)
{}

int diff_can_quit_early(struct diff_options *opt)
{}

/*
 * Shall changes to this submodule be ignored?
 *
 * Submodule changes can be configured to be ignored separately for each path,
 * but that configuration can be overridden from the command line.
 */
static int is_submodule_ignored(const char *path, struct diff_options *options)
{}

void compute_diffstat(struct diff_options *options,
		      struct diffstat_t *diffstat,
		      struct diff_queue_struct *q)
{}

void diff_addremove(struct diff_options *options,
		    int addremove, unsigned mode,
		    const struct object_id *oid,
		    int oid_valid,
		    const char *concatpath, unsigned dirty_submodule)
{}

void diff_change(struct diff_options *options,
		 unsigned old_mode, unsigned new_mode,
		 const struct object_id *old_oid,
		 const struct object_id *new_oid,
		 int old_oid_valid, int new_oid_valid,
		 const char *concatpath,
		 unsigned old_dirty_submodule, unsigned new_dirty_submodule)
{}

struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)
{}

static char *run_textconv(struct repository *r,
			  const char *pgm,
			  struct diff_filespec *spec,
			  size_t *outsize)
{}

size_t fill_textconv(struct repository *r,
		     struct userdiff_driver *driver,
		     struct diff_filespec *df,
		     char **outbuf)
{}

int textconv_object(struct repository *r,
		    const char *path,
		    unsigned mode,
		    const struct object_id *oid,
		    int oid_valid,
		    char **buf,
		    unsigned long *buf_size)
{}

void setup_diff_pager(struct diff_options *opt)
{}