1#ifndef APPLY_H 2#define APPLY_H 3 4enum apply_ws_error_action { 5 nowarn_ws_error, 6 warn_on_ws_error, 7 die_on_ws_error, 8 correct_ws_error 9}; 10 11enum apply_ws_ignore { 12 ignore_ws_none, 13 ignore_ws_change 14}; 15 16/* 17 * We need to keep track of how symlinks in the preimage are 18 * manipulated by the patches. A patch to add a/b/c where a/b 19 * is a symlink should not be allowed to affect the directory 20 * the symlink points at, but if the same patch removes a/b, 21 * it is perfectly fine, as the patch removes a/b to make room 22 * to create a directory a/b so that a/b/c can be created. 23 * 24 * See also "struct string_list symlink_changes" in "struct 25 * apply_state". 26 */ 27#define APPLY_SYMLINK_GOES_AWAY 01 28#define APPLY_SYMLINK_IN_RESULT 02 29 30struct apply_state { 31const char*prefix; 32int prefix_length; 33 34/* These are lock_file related */ 35struct lock_file *lock_file; 36int newfd; 37 38/* These control what gets looked at and modified */ 39int apply;/* this is not a dry-run */ 40int cached;/* apply to the index only */ 41int check;/* preimage must match working tree, don't actually apply */ 42int check_index;/* preimage must match the indexed version */ 43int update_index;/* check_index && apply */ 44 45/* These control cosmetic aspect of the output */ 46int diffstat;/* just show a diffstat, and don't actually apply */ 47int numstat;/* just show a numeric diffstat, and don't actually apply */ 48int summary;/* just report creation, deletion, etc, and don't actually apply */ 49 50/* These boolean parameters control how the apply is done */ 51int allow_overlap; 52int apply_in_reverse; 53int apply_with_reject; 54int apply_verbosely; 55int no_add; 56int threeway; 57int unidiff_zero; 58int unsafe_paths; 59 60/* Other non boolean parameters */ 61const char*fake_ancestor; 62const char*patch_input_file; 63int line_termination; 64struct strbuf root; 65int p_value; 66int p_value_known; 67unsigned int p_context; 68 69/* Exclude and include path parameters */ 70struct string_list limit_by_name; 71int has_include; 72 73/* Various "current state" */ 74int linenr;/* current line number */ 75struct string_list symlink_changes;/* we have to track symlinks */ 76 77/* 78 * For "diff-stat" like behaviour, we keep track of the biggest change 79 * we've seen, and the longest filename. That allows us to do simple 80 * scaling. 81 */ 82int max_change; 83int max_len; 84 85/* 86 * Records filenames that have been touched, in order to handle 87 * the case where more than one patches touch the same file. 88 */ 89struct string_list fn_table; 90 91/* These control whitespace errors */ 92enum apply_ws_error_action ws_error_action; 93enum apply_ws_ignore ws_ignore_action; 94const char*whitespace_option; 95int whitespace_error; 96int squelch_whitespace_errors; 97int applied_after_fixing_ws; 98}; 99 100externintparse_whitespace_option(struct apply_state *state, 101const char*option); 102externintparse_ignorewhitespace_option(struct apply_state *state, 103const char*option); 104 105externintinit_apply_state(struct apply_state *state, 106const char*prefix, 107struct lock_file *lock_file); 108externvoidclear_apply_state(struct apply_state *state); 109externintcheck_apply_state(struct apply_state *state,int force_apply); 110 111#endif