summaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-05-24 08:11:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-01 17:10:16 (GMT)
commit6c0c2bf56c7a3484d157661fb4660f5aefe67a83 (patch)
treed8544839a20e5947732ace585a33022a8344b750 /builtin/apply.c
parent1ff36a107f609978dedd8c5b56aad8ca6276f975 (diff)
downloadgit-6c0c2bf56c7a3484d157661fb4660f5aefe67a83.zip
git-6c0c2bf56c7a3484d157661fb4660f5aefe67a83.tar.gz
git-6c0c2bf56c7a3484d157661fb4660f5aefe67a83.tar.bz2
builtin/apply: move 'unsafe_paths' global into 'struct apply_state'
To libify the apply functionality the 'unsafe_paths' 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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 604e7bf..4ef83c1 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -44,6 +44,7 @@ struct apply_state {
int no_add;
int threeway;
int unidiff_zero;
+ int unsafe_paths;
};
/*
@@ -54,7 +55,6 @@ static int newfd = -1;
static int state_p_value = 1;
static int p_value_known;
static int apply = 1;
-static int unsafe_paths;
static const char *fake_ancestor;
static int line_termination = '\n';
static unsigned int p_context = UINT_MAX;
@@ -3827,7 +3827,7 @@ static int check_patch(struct apply_state *state, struct patch *patch)
}
}
- if (!unsafe_paths)
+ if (!state->unsafe_paths)
die_on_unsafe_path(patch);
/*
@@ -4616,7 +4616,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
N_("make sure the patch is applicable to the current index")),
OPT_BOOL(0, "cached", &state.cached,
N_("apply a patch without touching the working tree")),
- OPT_BOOL(0, "unsafe-paths", &unsafe_paths,
+ OPT_BOOL(0, "unsafe-paths", &state.unsafe_paths,
N_("accept a patch that touches outside the working area")),
OPT_BOOL(0, "apply", &force_apply,
N_("also apply the patch (use with --stat/--summary/--check)")),
@@ -4685,7 +4685,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
state.check_index = 1;
}
if (state.check_index)
- unsafe_paths = 0;
+ state.unsafe_paths = 0;
for (i = 0; i < argc; i++) {
const char *arg = argv[i];