Signed-off-by: Christian Couder <chrisc...@tuxfamily.org>
---
 builtin/apply.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index d5bc30f..37879de 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -26,12 +26,15 @@ struct apply_state {
        int prefix_length;
        int newfd;
 
+       /*
+        *  --check turns on checking that the working tree matches the
+        *    files that are being modified, but doesn't apply the patch
+        */
+       int check;
        int unidiff_zero;
 };
 
 /*
- *  --check turns on checking that the working tree matches the
- *    files that are being modified, but doesn't apply the patch
  *  --stat does just a diffstat, and doesn't actually apply
  *  --numstat does numeric diffstat, and doesn't actually apply
  *  --index-info shows the old and new index info for paths if available.
@@ -47,7 +50,6 @@ static int cached;
 static int diffstat;
 static int numstat;
 static int summary;
-static int check;
 static int apply = 1;
 static int apply_in_reverse;
 static int apply_with_reject;
@@ -2055,7 +2057,7 @@ static int parse_chunk(struct apply_state *state, char 
*buffer, unsigned long si
                 * without metadata change.  A binary patch appears
                 * empty to us here.
                 */
-               if ((apply || check) &&
+               if ((apply || state->check) &&
                    (!patch->is_binary && !metadata_changes(patch)))
                        die(_("patch with only garbage at line %d"), linenr);
        }
@@ -4439,7 +4441,7 @@ static int apply_patch(struct apply_state *state,
                        die(_("unable to read index file"));
        }
 
-       if ((check || apply) &&
+       if ((state->check || apply) &&
            check_patch_list(state, list) < 0 &&
            !apply_with_reject)
                exit(1);
@@ -4559,7 +4561,7 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
                        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")),
-               OPT_BOOL(0, "check", &check,
+               OPT_BOOL(0, "check", &state.check,
                        N_("instead of applying the patch, see if the patch is 
applicable")),
                OPT_BOOL(0, "index", &check_index,
                        N_("make sure the patch is applicable to the current 
index")),
@@ -4633,7 +4635,7 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
        }
        if (apply_with_reject)
                apply = apply_verbosely = 1;
-       if (!force_apply && (diffstat || numstat || summary || check || 
fake_ancestor))
+       if (!force_apply && (diffstat || numstat || summary || state.check || 
fake_ancestor))
                apply = 0;
        if (check_index && is_not_gitdir)
                die(_("--index outside a repository"));
-- 
2.8.0.rc1.49.gca61272

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to