apply: rename and move opt constants to apply.h
The constants for the "inaccurate-eof" and the "recount" options will be used in both "apply.c" and "builtin/apply.c", so they need to go into "apply.h", and therefore they need a name that is more specific to the API they belong to. Helped-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Sep 4, 2016 at 22:18 UTC
803bf4e012687d92f4c136febe0881852738d57d
2 files changed
+11
-7
apply.h
+7
@@ -108,4 +108,11 @@ extern int init_apply_state(struct apply_state *state,
108
extern void clear_apply_state(struct apply_state *state);
109
extern int check_apply_state(struct apply_state *state, int force_apply);
110
111
+/*
112
+ * Some aspects of the apply behavior are controlled by the following
113
+ * bits in the "options" parameter passed to apply_all_patches().
114
+ */
115
+#define APPLY_OPT_INACCURATE_EOF (1<<0) /* accept inaccurate eof */
116
+#define APPLY_OPT_RECOUNT (1<<1) /* accept inaccurate line count */
117
+
118
#endif
builtin/apply.c
+4
-7
@@ -4463,9 +4463,6 @@ static int write_out_results(struct apply_state *state, struct patch *list)
4463
4464
static struct lock_file lock_file;
4465
4466
-#define INACCURATE_EOF (1<<0)
4467
-#define RECOUNT (1<<1)
4468
-
4466
/*
4467
* Try to apply a patch.
4468
*
@@ -4495,8 +4492,8 @@ static int apply_patch(struct apply_state *state,
4492
int nr;
4493
4494
patch = xcalloc(1, sizeof(*patch));
4498
- patch->inaccurate_eof = !!(options & INACCURATE_EOF);
4499
- patch->recount = !!(options & RECOUNT);
4495
+ patch->inaccurate_eof = !!(options & APPLY_OPT_INACCURATE_EOF);
4496
+ patch->recount = !!(options & APPLY_OPT_RECOUNT);
4497
nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch);
4498
if (nr < 0) {
4499
free_patch(patch);
@@ -4811,10 +4808,10 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
4808
OPT__VERBOSE(&state.apply_verbosely, N_("be verbose")),
4809
OPT_BIT(0, "inaccurate-eof", &options,
4810
N_("tolerate incorrectly detected missing new-line at the end of file"),
4814
- INACCURATE_EOF),
4811
+ APPLY_OPT_INACCURATE_EOF),
4812
OPT_BIT(0, "recount", &options,
4813
N_("do not trust the line counts in the hunk headers"),
4817
- RECOUNT),
4814
+ APPLY_OPT_RECOUNT),
4815
{ OPTION_CALLBACK, 0, "directory", &state, N_("root"),
4816
N_("prepend <root> to all filenames"),
4817
0, apply_option_parse_directory },