Skip to content

Commit 803bf4e

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da8e30d commit 803bf4e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

apply.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,11 @@ extern int init_apply_state(struct apply_state *state,
108108
extern void clear_apply_state(struct apply_state *state);
109109
extern int check_apply_state(struct apply_state *state, int force_apply);
110110

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+
111118
#endif

builtin/apply.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,9 +4463,6 @@ static int write_out_results(struct apply_state *state, struct patch *list)
44634463

44644464
static struct lock_file lock_file;
44654465

4466-
#define INACCURATE_EOF (1<<0)
4467-
#define RECOUNT (1<<1)
4468-
44694466
/*
44704467
* Try to apply a patch.
44714468
*
@@ -4495,8 +4492,8 @@ static int apply_patch(struct apply_state *state,
44954492
int nr;
44964493

44974494
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);
45004497
nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch);
45014498
if (nr < 0) {
45024499
free_patch(patch);
@@ -4811,10 +4808,10 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
48114808
OPT__VERBOSE(&state.apply_verbosely, N_("be verbose")),
48124809
OPT_BIT(0, "inaccurate-eof", &options,
48134810
N_("tolerate incorrectly detected missing new-line at the end of file"),
4814-
INACCURATE_EOF),
4811+
APPLY_OPT_INACCURATE_EOF),
48154812
OPT_BIT(0, "recount", &options,
48164813
N_("do not trust the line counts in the hunk headers"),
4817-
RECOUNT),
4814+
APPLY_OPT_RECOUNT),
48184815
{ OPTION_CALLBACK, 0, "directory", &state, N_("root"),
48194816
N_("prepend <root> to all filenames"),
48204817
0, apply_option_parse_directory },

0 commit comments

Comments
 (0)