summaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-05-24 08:11:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-01 17:10:16 (GMT)
commita48f9bb1b31329b29eed9808844c147f613b59ad (patch)
treee6b94d3efaf318318da6801f4a6cb337ae345f27 /builtin/apply.c
parenta0bfaf0796e416bb1cecd03e30af3e189a039a29 (diff)
downloadgit-a48f9bb1b31329b29eed9808844c147f613b59ad.zip
git-a48f9bb1b31329b29eed9808844c147f613b59ad.tar.gz
git-a48f9bb1b31329b29eed9808844c147f613b59ad.tar.bz2
builtin/apply: move 'p_context' global into 'struct apply_state'
To libify the apply functionality the 'p_context' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 59b0f1b..3c9f052 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -49,6 +49,7 @@ struct apply_state {
/* Other non boolean parameters */
const char *fake_ancestor;
int line_termination;
+ unsigned int p_context;
};
static int newfd = -1;
@@ -56,7 +57,6 @@ static int newfd = -1;
static int state_p_value = 1;
static int p_value_known;
static int apply = 1;
-static unsigned int p_context = UINT_MAX;
static const char * const apply_usage[] = {
N_("git apply [<options>] [<patch>...]"),
NULL
@@ -2872,7 +2872,7 @@ static int apply_one_fragment(struct apply_state *state,
break;
/* Am I at my context limits? */
- if ((leading <= p_context) && (trailing <= p_context))
+ if ((leading <= state->p_context) && (trailing <= state->p_context))
break;
if (match_beginning || match_end) {
match_beginning = match_end = 0;
@@ -4566,6 +4566,7 @@ static void init_apply_state(struct apply_state *state, const char *prefix)
state->prefix = prefix;
state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
state->line_termination = '\n';
+ state->p_context = UINT_MAX;
git_apply_config();
if (apply_default_whitespace)
@@ -4628,7 +4629,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
/* Think twice before adding "--nul" synonym to this */
OPT_SET_INT('z', NULL, &state.line_termination,
N_("paths are separated with NUL character"), '\0'),
- OPT_INTEGER('C', NULL, &p_context,
+ OPT_INTEGER('C', NULL, &state.p_context,
N_("ensure at least <n> lines of context match")),
{ OPTION_CALLBACK, 0, "whitespace", &whitespace_option, N_("action"),
N_("detect new or modified lines that have whitespace errors"),