summaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-05-24 08:10:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-01 17:10:16 (GMT)
commitb12e888f7a9489b964ad266b27d7fcfa62fa78e4 (patch)
tree02a7744b75c17ab503ee8852b4dfd7411a40cb73 /builtin/apply.c
parent79a3efda795a88403cea3e9ff321b4b668f393d9 (diff)
downloadgit-b12e888f7a9489b964ad266b27d7fcfa62fa78e4.zip
git-b12e888f7a9489b964ad266b27d7fcfa62fa78e4.tar.gz
git-b12e888f7a9489b964ad266b27d7fcfa62fa78e4.tar.bz2
builtin/apply: move 'threeway' global into 'struct apply_state'
To libify the apply functionality the 'threeway' 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.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index f174a42..d00017b 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -41,6 +41,7 @@ struct apply_state {
int apply_in_reverse;
int apply_with_reject;
int apply_verbosely;
+ int threeway;
int unidiff_zero;
};
@@ -53,7 +54,6 @@ static int state_p_value = 1;
static int p_value_known;
static int apply = 1;
static int no_add;
-static int threeway;
static int unsafe_paths;
static const char *fake_ancestor;
static int line_termination = '\n';
@@ -3491,7 +3491,7 @@ static int apply_data(struct apply_state *state, struct patch *patch,
if (patch->direct_to_threeway ||
apply_fragments(state, &image, patch) < 0) {
/* Note: with --reject, apply_fragments() returns 0 */
- if (!threeway || try_threeway(state, &image, patch, st, ce) < 0)
+ if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0)
return -1;
}
patch->result = image.buf;
@@ -3786,7 +3786,7 @@ static int check_patch(struct apply_state *state, struct patch *patch)
((0 < patch->is_new) || patch->is_rename || patch->is_copy)) {
int err = check_to_create(state, new_name, ok_if_exists);
- if (err && threeway) {
+ if (err && state->threeway) {
patch->direct_to_threeway = 1;
} else switch (err) {
case 0:
@@ -4620,7 +4620,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
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)")),
- OPT_BOOL('3', "3way", &threeway,
+ OPT_BOOL('3', "3way", &state.threeway,
N_( "attempt three-way merge if a patch does not apply")),
OPT_FILENAME(0, "build-fake-ancestor", &fake_ancestor,
N_("build a temporary index based on embedded index information")),
@@ -4664,11 +4664,11 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, state.prefix, builtin_apply_options,
apply_usage, 0);
- if (state.apply_with_reject && threeway)
+ if (state.apply_with_reject && state.threeway)
die("--reject and --3way cannot be used together.");
- if (state.cached && threeway)
+ if (state.cached && state.threeway)
die("--cached and --3way cannot be used together.");
- if (threeway) {
+ if (state.threeway) {
if (is_not_gitdir)
die(_("--3way outside a repository"));
state.check_index = 1;