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