builtin/apply: move 'numstat' global into 'struct apply_state'

To libify the apply functionality the 'numstat' 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>

Christian Couder committed May 24, 2016 at 10:10 UTC 179070b91c0ae1baf889f083596398a4f72286ea
1 file changed +4 -5
builtin/apply.c
+4 -5
@@ -33,6 +33,7 @@ struct apply_state {
33
34 /* These control cosmetic aspect of the output */
35 int diffstat; /* just show a diffstat, and don't actually apply */
36 + int numstat; /* just show a numeric diffstat, and don't actually apply */
37
38 /* These boolean parameters control how the apply is done */
39 int allow_overlap;
@@ -43,14 +44,12 @@ struct apply_state {
44 };
45
46 /*
46 - * --numstat does numeric diffstat, and doesn't actually apply
47 * --index-info shows the old and new index info for paths if available.
48 */
49 static int newfd = -1;
50
51 static int state_p_value = 1;
52 static int p_value_known;
53 -static int numstat;
53 static int summary;
54 static int apply = 1;
55 static int no_add;
@@ -4490,7 +4489,7 @@ static int apply_patch(struct apply_state *state,
4489 if (state->diffstat)
4490 stat_patch_list(list);
4491
4493 - if (numstat)
4492 + if (state->numstat)
4493 numstat_patch_list(list);
4494
4495 if (summary)
@@ -4607,7 +4606,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
4606 N_("instead of applying the patch, output diffstat for the input")),
4607 OPT_NOOP_NOARG(0, "allow-binary-replacement"),
4608 OPT_NOOP_NOARG(0, "binary"),
4610 - OPT_BOOL(0, "numstat", &numstat,
4609 + OPT_BOOL(0, "numstat", &state.numstat,
4610 N_("show number of added and deleted lines in decimal notation")),
4611 OPT_BOOL(0, "summary", &summary,
4612 N_("instead of applying the patch, output a summary for the input")),
@@ -4676,7 +4675,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
4675 }
4676 if (state.apply_with_reject)
4677 apply = state.apply_verbosely = 1;
4679 - if (!force_apply && (state.diffstat || numstat || summary || state.check || fake_ancestor))
4678 + if (!force_apply && (state.diffstat || state.numstat || summary || state.check || fake_ancestor))
4679 apply = 0;
4680 if (state.check_index && is_not_gitdir)
4681 die(_("--index outside a repository"));