apply.hon commit l10n: git.pot: v2.20.0 round 3 (5 new, 3 removed) (578d8ea)
   1#ifndef APPLY_H
   2#define APPLY_H
   3
   4#include "lockfile.h"
   5#include "string-list.h"
   6
   7struct repository;
   8
   9enum apply_ws_error_action {
  10        nowarn_ws_error,
  11        warn_on_ws_error,
  12        die_on_ws_error,
  13        correct_ws_error
  14};
  15
  16enum apply_ws_ignore {
  17        ignore_ws_none,
  18        ignore_ws_change
  19};
  20
  21enum apply_verbosity {
  22        verbosity_silent = -1,
  23        verbosity_normal = 0,
  24        verbosity_verbose = 1
  25};
  26
  27/*
  28 * We need to keep track of how symlinks in the preimage are
  29 * manipulated by the patches.  A patch to add a/b/c where a/b
  30 * is a symlink should not be allowed to affect the directory
  31 * the symlink points at, but if the same patch removes a/b,
  32 * it is perfectly fine, as the patch removes a/b to make room
  33 * to create a directory a/b so that a/b/c can be created.
  34 *
  35 * See also "struct string_list symlink_changes" in "struct
  36 * apply_state".
  37 */
  38#define APPLY_SYMLINK_GOES_AWAY 01
  39#define APPLY_SYMLINK_IN_RESULT 02
  40
  41struct apply_state {
  42        const char *prefix;
  43
  44        /* Lock file */
  45        struct lock_file lock_file;
  46
  47        /* These control what gets looked at and modified */
  48        int apply; /* this is not a dry-run */
  49        int cached; /* apply to the index only */
  50        int check; /* preimage must match working tree, don't actually apply */
  51        int check_index; /* preimage must match the indexed version */
  52        int update_index; /* check_index && apply */
  53        int ita_only;     /* add intent-to-add entries to the index */
  54
  55        /* These control cosmetic aspect of the output */
  56        int diffstat; /* just show a diffstat, and don't actually apply */
  57        int numstat; /* just show a numeric diffstat, and don't actually apply */
  58        int summary; /* just report creation, deletion, etc, and don't actually apply */
  59
  60        /* These boolean parameters control how the apply is done */
  61        int allow_overlap;
  62        int apply_in_reverse;
  63        int apply_with_reject;
  64        int no_add;
  65        int threeway;
  66        int unidiff_zero;
  67        int unsafe_paths;
  68
  69        /* Other non boolean parameters */
  70        struct repository *repo;
  71        const char *index_file;
  72        enum apply_verbosity apply_verbosity;
  73        const char *fake_ancestor;
  74        const char *patch_input_file;
  75        int line_termination;
  76        struct strbuf root;
  77        int p_value;
  78        int p_value_known;
  79        unsigned int p_context;
  80
  81        /* Exclude and include path parameters */
  82        struct string_list limit_by_name;
  83        int has_include;
  84
  85        /* Various "current state" */
  86        int linenr; /* current line number */
  87        struct string_list symlink_changes; /* we have to track symlinks */
  88
  89        /*
  90         * For "diff-stat" like behaviour, we keep track of the biggest change
  91         * we've seen, and the longest filename. That allows us to do simple
  92         * scaling.
  93         */
  94        int max_change;
  95        int max_len;
  96
  97        /*
  98         * Records filenames that have been touched, in order to handle
  99         * the case where more than one patches touch the same file.
 100         */
 101        struct string_list fn_table;
 102
 103        /*
 104         * This is to save reporting routines before using
 105         * set_error_routine() or set_warn_routine() to install muting
 106         * routines when in verbosity_silent mode.
 107         */
 108        void (*saved_error_routine)(const char *err, va_list params);
 109        void (*saved_warn_routine)(const char *warn, va_list params);
 110
 111        /* These control whitespace errors */
 112        enum apply_ws_error_action ws_error_action;
 113        enum apply_ws_ignore ws_ignore_action;
 114        const char *whitespace_option;
 115        int whitespace_error;
 116        int squelch_whitespace_errors;
 117        int applied_after_fixing_ws;
 118};
 119
 120int apply_parse_options(int argc, const char **argv,
 121                        struct apply_state *state,
 122                        int *force_apply, int *options,
 123                        const char * const *apply_usage);
 124int init_apply_state(struct apply_state *state,
 125                     struct repository *repo,
 126                     const char *prefix);
 127void clear_apply_state(struct apply_state *state);
 128int check_apply_state(struct apply_state *state, int force_apply);
 129
 130/*
 131 * Some aspects of the apply behavior are controlled by the following
 132 * bits in the "options" parameter passed to apply_all_patches().
 133 */
 134#define APPLY_OPT_INACCURATE_EOF        (1<<0) /* accept inaccurate eof */
 135#define APPLY_OPT_RECOUNT               (1<<1) /* accept inaccurate line count */
 136
 137int apply_all_patches(struct apply_state *state,
 138                      int argc, const char **argv,
 139                      int options);
 140
 141#endif