4 enum apply_ws_error_action
{
11 enum apply_ws_ignore
{
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.
24 * See also "struct string_list symlink_changes" in "struct
27 #define APPLY_SYMLINK_GOES_AWAY 01
28 #define APPLY_SYMLINK_IN_RESULT 02
34 /* These are lock_file related */
35 struct lock_file
*lock_file
;
38 /* These control what gets looked at and modified */
39 int apply
; /* this is not a dry-run */
40 int cached
; /* apply to the index only */
41 int check
; /* preimage must match working tree, don't actually apply */
42 int check_index
; /* preimage must match the indexed version */
43 int update_index
; /* check_index && apply */
45 /* These control cosmetic aspect of the output */
46 int diffstat
; /* just show a diffstat, and don't actually apply */
47 int numstat
; /* just show a numeric diffstat, and don't actually apply */
48 int summary
; /* just report creation, deletion, etc, and don't actually apply */
50 /* These boolean parameters control how the apply is done */
53 int apply_with_reject
;
60 /* Other non boolean parameters */
61 const char *fake_ancestor
;
62 const char *patch_input_file
;
67 unsigned int p_context
;
69 /* Exclude and include path parameters */
70 struct string_list limit_by_name
;
73 /* Various "current state" */
74 int linenr
; /* current line number */
75 struct string_list symlink_changes
; /* we have to track symlinks */
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
86 * Records filenames that have been touched, in order to handle
87 * the case where more than one patches touch the same file.
89 struct string_list fn_table
;
91 /* These control whitespace errors */
92 enum apply_ws_error_action ws_error_action
;
93 enum apply_ws_ignore ws_ignore_action
;
94 const char *whitespace_option
;
96 int squelch_whitespace_errors
;
97 int applied_after_fixing_ws
;
100 extern int parse_whitespace_option(struct apply_state
*state
,
102 extern int parse_ignorewhitespace_option(struct apply_state
*state
,
105 extern int apply_option_parse_exclude(const struct option
*opt
,
106 const char *arg
, int unset
);
107 extern int apply_option_parse_include(const struct option
*opt
,
108 const char *arg
, int unset
);
109 extern int apply_option_parse_p(const struct option
*opt
,
112 extern int apply_option_parse_whitespace(const struct option
*opt
,
113 const char *arg
, int unset
);
114 extern int apply_option_parse_directory(const struct option
*opt
,
115 const char *arg
, int unset
);
116 extern int apply_option_parse_space_change(const struct option
*opt
,
117 const char *arg
, int unset
);
119 extern int init_apply_state(struct apply_state
*state
,
121 struct lock_file
*lock_file
);
122 extern void clear_apply_state(struct apply_state
*state
);
123 extern int check_apply_state(struct apply_state
*state
, int force_apply
);
126 * Some aspects of the apply behavior are controlled by the following
127 * bits in the "options" parameter passed to apply_all_patches().
129 #define APPLY_OPT_INACCURATE_EOF (1<<0) /* accept inaccurate eof */
130 #define APPLY_OPT_RECOUNT (1<<1) /* accept inaccurate line count */
132 extern int apply_all_patches(struct apply_state
*state
,