builtin/apply: move 'numstat' global into 'struct apply_state'
authorChristian Couder <christian.couder@gmail.com>
Tue, 24 May 2016 08:10:57 +0000 (10:10 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Jun 2016 17:10:16 +0000 (10:10 -0700)
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>
builtin/apply.c
index d940125ee20d02e52a16065832d3d681d3e44f61..47a45a71d51889d99cf2c442d6b5923384b9f78d 100644 (file)
@@ -33,6 +33,7 @@ struct apply_state {
 
        /* These control cosmetic aspect of the output */
        int diffstat; /* just show a diffstat, and don't actually apply */
+       int numstat; /* just show a numeric diffstat, and don't actually apply */
 
        /* These boolean parameters control how the apply is done */
        int allow_overlap;
@@ -43,14 +44,12 @@ struct apply_state {
 };
 
 /*
- *  --numstat does numeric diffstat, and doesn't actually apply
  *  --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 numstat;
 static int summary;
 static int apply = 1;
 static int no_add;
@@ -4490,7 +4489,7 @@ static int apply_patch(struct apply_state *state,
        if (state->diffstat)
                stat_patch_list(list);
 
-       if (numstat)
+       if (state->numstat)
                numstat_patch_list(list);
 
        if (summary)
@@ -4607,7 +4606,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
                        N_("instead of applying the patch, output diffstat for the input")),
                OPT_NOOP_NOARG(0, "allow-binary-replacement"),
                OPT_NOOP_NOARG(0, "binary"),
-               OPT_BOOL(0, "numstat", &numstat,
+               OPT_BOOL(0, "numstat", &state.numstat,
                        N_("show number of added and deleted lines in decimal notation")),
                OPT_BOOL(0, "summary", &summary,
                        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)
        }
        if (state.apply_with_reject)
                apply = state.apply_verbosely = 1;
-       if (!force_apply && (state.diffstat || numstat || summary || state.check || fake_ancestor))
+       if (!force_apply && (state.diffstat || state.numstat || summary || state.check || fake_ancestor))
                apply = 0;
        if (state.check_index && is_not_gitdir)
                die(_("--index outside a repository"));