summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-05-24 08:11:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-01 17:10:16 (GMT)
commita0bfaf0796e416bb1cecd03e30af3e189a039a29 (patch)
tree8cf5b6c0aa9f7b43105a4b47e824f155ef794c80 /builtin
parentf4c9eaa49c5ed87b304a40b95b1d06d46a8cbfa9 (diff)
downloadgit-a0bfaf0796e416bb1cecd03e30af3e189a039a29.zip
git-a0bfaf0796e416bb1cecd03e30af3e189a039a29.tar.gz
git-a0bfaf0796e416bb1cecd03e30af3e189a039a29.tar.bz2
builtin/apply: move 'fake_ancestor' global into 'struct apply_state'
To libify the apply functionality the 'fake_ancestor' variable should not be static and global to the file. Let's move it into 'struct apply_state'. By the way remove a comment about '--index-info' that was renamed '--build-fake-ancestor' in commit 26b28007689d27a921ea90e5a29fc8eb74b0d297 (apply: get rid of --index-info in favor of --build-fake-ancestor, Sep 17 2007). 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')
-rw-r--r--builtin/apply.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 95cd60a..59b0f1b 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -47,18 +47,15 @@ struct apply_state {
int unsafe_paths;
/* Other non boolean parameters */
+ const char *fake_ancestor;
int line_termination;
};
-/*
- * --index-info shows the old and new index info for paths if available.
- */
static int newfd = -1;
static int state_p_value = 1;
static int p_value_known;
static int apply = 1;
-static const char *fake_ancestor;
static unsigned int p_context = UINT_MAX;
static const char * const apply_usage[] = {
N_("git apply [<options>] [<patch>...]"),
@@ -4486,8 +4483,8 @@ static int apply_patch(struct apply_state *state,
return 1;
}
- if (fake_ancestor)
- build_fake_ancestor(list, fake_ancestor);
+ if (state->fake_ancestor)
+ build_fake_ancestor(list, state->fake_ancestor);
if (state->diffstat)
stat_patch_list(list);
@@ -4626,7 +4623,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
N_("also apply the patch (use with --stat/--summary/--check)")),
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,
+ OPT_FILENAME(0, "build-fake-ancestor", &state.fake_ancestor,
N_("build a temporary index based on embedded index information")),
/* Think twice before adding "--nul" synonym to this */
OPT_SET_INT('z', NULL, &state.line_termination,
@@ -4679,7 +4676,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
}
if (state.apply_with_reject)
apply = state.apply_verbosely = 1;
- if (!force_apply && (state.diffstat || state.numstat || state.summary || state.check || fake_ancestor))
+ if (!force_apply && (state.diffstat || state.numstat || state.summary || state.check || state.fake_ancestor))
apply = 0;
if (state.check_index && is_not_gitdir)
die(_("--index outside a repository"));