builtin/apply: move 'check' global into 'struct apply_state'
To libify the apply functionality the 'check' 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>
maint
Christian Couder9 years agocommitted byJunio C Hamano
/* These control what gets looked at and modified */
int check; /* preimage must match working tree, don't actually apply */
/* These boolean parameters control how the apply is done */
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.
@ -48,7 +49,6 @@ static int cached;
@@ -48,7 +49,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;
@ -2053,7 +2053,7 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si
@@ -2053,7 +2053,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"), state_linenr);
}
@ -4440,7 +4440,7 @@ static int apply_patch(struct apply_state *state,
@@ -4440,7 +4440,7 @@ static int apply_patch(struct apply_state *state,