#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "abspath.h"
#include "base85.h"
#include "config.h"
#include "object-store-ll.h"
#include "delta.h"
#include "diff.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "xdiff-interface.h"
#include "merge-ll.h"
#include "lockfile.h"
#include "name-hash.h"
#include "object-name.h"
#include "object-file.h"
#include "parse-options.h"
#include "path.h"
#include "quote.h"
#include "read-cache.h"
#include "repository.h"
#include "rerere.h"
#include "apply.h"
#include "entry.h"
#include "setup.h"
#include "symlinks.h"
#include "wildmatch.h"
#include "ws.h"
struct gitdiff_data { … };
static void git_apply_config(void)
{ … }
static int parse_whitespace_option(struct apply_state *state, const char *option)
{ … }
static int parse_ignorewhitespace_option(struct apply_state *state,
const char *option)
{ … }
int init_apply_state(struct apply_state *state,
struct repository *repo,
const char *prefix)
{ … }
void clear_apply_state(struct apply_state *state)
{ … }
static void mute_routine(const char *msg UNUSED, va_list params UNUSED)
{ … }
int check_apply_state(struct apply_state *state, int force_apply)
{ … }
static void set_default_whitespace_mode(struct apply_state *state)
{ … }
struct fragment { … };
#define binary_patch_method …
#define BINARY_DELTA_DEFLATED …
#define BINARY_LITERAL_DEFLATED …
static void free_fragment_list(struct fragment *list)
{ … }
void release_patch(struct patch *patch)
{ … }
static void free_patch(struct patch *patch)
{ … }
static void free_patch_list(struct patch *list)
{ … }
struct line { … };
struct image { … };
#define IMAGE_INIT …
static void image_init(struct image *image)
{ … }
static void image_clear(struct image *image)
{ … }
static uint32_t hash_line(const char *cp, size_t len)
{ … }
static void image_add_line(struct image *img, const char *bol, size_t len, unsigned flag)
{ … }
static void image_prepare(struct image *image, char *buf, size_t len,
int prepare_linetable)
{ … }
static void image_remove_first_line(struct image *img)
{ … }
static void image_remove_last_line(struct image *img)
{ … }
static void say_patch_name(FILE *output, const char *fmt, struct patch *patch)
{ … }
#define SLOP …
#define MAX_APPLY_SIZE …
static int read_patch_file(struct strbuf *sb, int fd)
{ … }
static unsigned long linelen(const char *buffer, unsigned long size)
{ … }
static int is_dev_null(const char *str)
{ … }
#define TERM_SPACE …
#define TERM_TAB …
static int name_terminate(int c, int terminate)
{ … }
static char *squash_slash(char *name)
{ … }
static char *find_name_gnu(struct strbuf *root,
const char *line,
int p_value)
{ … }
static size_t sane_tz_len(const char *line, size_t len)
{ … }
static size_t tz_with_colon_len(const char *line, size_t len)
{ … }
static size_t date_len(const char *line, size_t len)
{ … }
static size_t short_time_len(const char *line, size_t len)
{ … }
static size_t fractional_time_len(const char *line, size_t len)
{ … }
static size_t trailing_spaces_len(const char *line, size_t len)
{ … }
static size_t diff_timestamp_len(const char *line, size_t len)
{ … }
static char *find_name_common(struct strbuf *root,
const char *line,
const char *def,
int p_value,
const char *end,
int terminate)
{ … }
static char *find_name(struct strbuf *root,
const char *line,
char *def,
int p_value,
int terminate)
{ … }
static char *find_name_traditional(struct strbuf *root,
const char *line,
char *def,
int p_value)
{ … }
static int guess_p_value(struct apply_state *state, const char *nameline)
{ … }
static int has_epoch_timestamp(const char *nameline)
{ … }
static int parse_traditional_patch(struct apply_state *state,
const char *first,
const char *second,
struct patch *patch)
{ … }
static int gitdiff_hdrend(struct gitdiff_data *state UNUSED,
const char *line UNUSED,
struct patch *patch UNUSED)
{ … }
#define DIFF_OLD_NAME …
#define DIFF_NEW_NAME …
static int gitdiff_verify_name(struct gitdiff_data *state,
const char *line,
int isnull,
char **name,
int side)
{ … }
static int gitdiff_oldname(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_newname(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int parse_mode_line(const char *line, int linenr, unsigned int *mode)
{ … }
static int gitdiff_oldmode(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_newmode(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_delete(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_newfile(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_copysrc(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_copydst(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_renamesrc(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_renamedst(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_similarity(struct gitdiff_data *state UNUSED,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_dissimilarity(struct gitdiff_data *state UNUSED,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_index(struct gitdiff_data *state,
const char *line,
struct patch *patch)
{ … }
static int gitdiff_unrecognized(struct gitdiff_data *state UNUSED,
const char *line UNUSED,
struct patch *patch UNUSED)
{ … }
static const char *skip_tree_prefix(int p_value,
const char *line,
int llen)
{ … }
static char *git_header_name(int p_value,
const char *line,
int llen)
{ … }
static int check_header_line(int linenr, struct patch *patch)
{ … }
int parse_git_diff_header(struct strbuf *root,
int *linenr,
int p_value,
const char *line,
int len,
unsigned int size,
struct patch *patch)
{ … }
static int parse_num(const char *line, unsigned long *p)
{ … }
static int parse_range(const char *line, int len, int offset, const char *expect,
unsigned long *p1, unsigned long *p2)
{ … }
static void recount_diff(const char *line, int size, struct fragment *fragment)
{ … }
static int parse_fragment_header(const char *line, int len, struct fragment *fragment)
{ … }
static int find_header(struct apply_state *state,
const char *line,
unsigned long size,
int *hdrsize,
struct patch *patch)
{ … }
static void record_ws_error(struct apply_state *state,
unsigned result,
const char *line,
int len,
int linenr)
{ … }
static void check_whitespace(struct apply_state *state,
const char *line,
int len,
unsigned ws_rule)
{ … }
static void check_old_for_crlf(struct patch *patch, const char *line, int len)
{ … }
static int parse_fragment(struct apply_state *state,
const char *line,
unsigned long size,
struct patch *patch,
struct fragment *fragment)
{ … }
static int parse_single_patch(struct apply_state *state,
const char *line,
unsigned long size,
struct patch *patch)
{ … }
static inline int metadata_changes(struct patch *patch)
{ … }
static char *inflate_it(const void *data, unsigned long size,
unsigned long inflated_size)
{ … }
static struct fragment *parse_binary_hunk(struct apply_state *state,
char **buf_p,
unsigned long *sz_p,
int *status_p,
int *used_p)
{ … }
static int parse_binary(struct apply_state *state,
char *buffer,
unsigned long size,
struct patch *patch)
{ … }
static void prefix_one(struct apply_state *state, char **name)
{ … }
static void prefix_patch(struct apply_state *state, struct patch *p)
{ … }
static void add_name_limit(struct apply_state *state,
const char *name,
int exclude)
{ … }
static int use_patch(struct apply_state *state, struct patch *p)
{ … }
static int parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch)
{ … }
static void reverse_patches(struct patch *p)
{ … }
static const char pluses[] = …;
static const char minuses[]= …;
static void show_stats(struct apply_state *state, struct patch *patch)
{ … }
static int read_old_data(struct stat *st, struct patch *patch,
const char *path, struct strbuf *buf)
{ … }
static void update_pre_post_images(struct image *preimage,
struct image *postimage,
char *buf, size_t len)
{ … }
static int fuzzy_matchlines(const char *s1, size_t n1,
const char *s2, size_t n2)
{ … }
static int line_by_line_fuzzy_match(struct image *img,
struct image *preimage,
struct image *postimage,
unsigned long current,
int current_lno,
int preimage_limit)
{ … }
static int match_fragment(struct apply_state *state,
struct image *img,
struct image *preimage,
struct image *postimage,
unsigned long current,
int current_lno,
unsigned ws_rule,
int match_beginning, int match_end)
{ … }
static int find_pos(struct apply_state *state,
struct image *img,
struct image *preimage,
struct image *postimage,
int line,
unsigned ws_rule,
int match_beginning, int match_end)
{ … }
static void update_image(struct apply_state *state,
struct image *img,
int applied_pos,
struct image *preimage,
struct image *postimage)
{ … }
static int apply_one_fragment(struct apply_state *state,
struct image *img, struct fragment *frag,
int inaccurate_eof, unsigned ws_rule,
int nth_fragment)
{ … }
static int apply_binary_fragment(struct apply_state *state,
struct image *img,
struct patch *patch)
{ … }
static int apply_binary(struct apply_state *state,
struct image *img,
struct patch *patch)
{ … }
static int apply_fragments(struct apply_state *state, struct image *img, struct patch *patch)
{ … }
static int read_blob_object(struct strbuf *buf, const struct object_id *oid, unsigned mode)
{ … }
static int read_file_or_gitlink(const struct cache_entry *ce, struct strbuf *buf)
{ … }
static struct patch *in_fn_table(struct apply_state *state, const char *name)
{ … }
#define PATH_TO_BE_DELETED …
#define PATH_WAS_DELETED …
static int to_be_deleted(struct patch *patch)
{ … }
static int was_deleted(struct patch *patch)
{ … }
static void add_to_fn_table(struct apply_state *state, struct patch *patch)
{ … }
static void prepare_fn_table(struct apply_state *state, struct patch *patch)
{ … }
static int checkout_target(struct index_state *istate,
struct cache_entry *ce, struct stat *st)
{ … }
static struct patch *previous_patch(struct apply_state *state,
struct patch *patch,
int *gone)
{ … }
static int verify_index_match(struct apply_state *state,
const struct cache_entry *ce,
struct stat *st)
{ … }
#define SUBMODULE_PATCH_WITHOUT_INDEX …
static int load_patch_target(struct apply_state *state,
struct strbuf *buf,
const struct cache_entry *ce,
struct stat *st,
struct patch *patch,
const char *name,
unsigned expected_mode)
{ … }
static int load_preimage(struct apply_state *state,
struct image *image,
struct patch *patch, struct stat *st,
const struct cache_entry *ce)
{ … }
static int resolve_to(struct image *image, const struct object_id *result_id)
{ … }
static int three_way_merge(struct apply_state *state,
struct image *image,
char *path,
const struct object_id *base,
const struct object_id *ours,
const struct object_id *theirs)
{ … }
static int load_current(struct apply_state *state,
struct image *image,
struct patch *patch)
{ … }
static int try_threeway(struct apply_state *state,
struct image *image,
struct patch *patch,
struct stat *st,
const struct cache_entry *ce)
{ … }
static int apply_data(struct apply_state *state, struct patch *patch,
struct stat *st, const struct cache_entry *ce)
{ … }
static int check_preimage(struct apply_state *state,
struct patch *patch,
struct cache_entry **ce,
struct stat *st)
{ … }
#define EXISTS_IN_INDEX …
#define EXISTS_IN_WORKTREE …
#define EXISTS_IN_INDEX_AS_ITA …
static int check_to_create(struct apply_state *state,
const char *new_name,
int ok_if_exists)
{ … }
static void prepare_symlink_changes(struct apply_state *state, struct patch *patch)
{ … }
static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *name)
{ … }
static int path_is_beyond_symlink(struct apply_state *state, const char *name_)
{ … }
static int check_unsafe_path(struct patch *patch)
{ … }
static int check_patch(struct apply_state *state, struct patch *patch)
{ … }
static int check_patch_list(struct apply_state *state, struct patch *patch)
{ … }
static int read_apply_cache(struct apply_state *state)
{ … }
static int get_current_oid(struct apply_state *state, const char *path,
struct object_id *oid)
{ … }
static int preimage_oid_in_gitlink_patch(struct patch *p, struct object_id *oid)
{ … }
static int build_fake_ancestor(struct apply_state *state, struct patch *list)
{ … }
static void stat_patch_list(struct apply_state *state, struct patch *patch)
{ … }
static void numstat_patch_list(struct apply_state *state,
struct patch *patch)
{ … }
static void show_file_mode_name(const char *newdelete, unsigned int mode, const char *name)
{ … }
static void show_mode_change(struct patch *p, int show_name)
{ … }
static void show_rename_copy(struct patch *p)
{ … }
static void summary_patch_list(struct patch *patch)
{ … }
static void patch_stats(struct apply_state *state, struct patch *patch)
{ … }
static int remove_file(struct apply_state *state, struct patch *patch, int rmdir_empty)
{ … }
static int add_index_file(struct apply_state *state,
const char *path,
unsigned mode,
void *buf,
unsigned long size)
{ … }
static int try_create_file(struct apply_state *state, const char *path,
unsigned int mode, const char *buf,
unsigned long size)
{ … }
static int create_one_file(struct apply_state *state,
char *path,
unsigned mode,
const char *buf,
unsigned long size)
{ … }
static int add_conflicted_stages_file(struct apply_state *state,
struct patch *patch)
{ … }
static int create_file(struct apply_state *state, struct patch *patch)
{ … }
static int write_out_one_result(struct apply_state *state,
struct patch *patch,
int phase)
{ … }
static int write_out_one_reject(struct apply_state *state, struct patch *patch)
{ … }
static int write_out_results(struct apply_state *state, struct patch *list)
{ … }
static int apply_patch(struct apply_state *state,
int fd,
const char *filename,
int options)
{ … }
static int apply_option_parse_exclude(const struct option *opt,
const char *arg, int unset)
{ … }
static int apply_option_parse_include(const struct option *opt,
const char *arg, int unset)
{ … }
static int apply_option_parse_p(const struct option *opt,
const char *arg,
int unset)
{ … }
static int apply_option_parse_space_change(const struct option *opt,
const char *arg, int unset)
{ … }
static int apply_option_parse_whitespace(const struct option *opt,
const char *arg, int unset)
{ … }
static int apply_option_parse_directory(const struct option *opt,
const char *arg, int unset)
{ … }
int apply_all_patches(struct apply_state *state,
int argc,
const char **argv,
int options)
{ … }
int apply_parse_options(int argc, const char **argv,
struct apply_state *state,
int *force_apply, int *options,
const char * const *apply_usage)
{ … }