/* These boolean parameters control how the apply is done */
int apply_in_reverse;
int apply_with_reject;
+ int apply_verbosely;
int unidiff_zero;
};
static int numstat;
static int summary;
static int apply = 1;
-static int apply_verbosely;
static int allow_overlap;
static int no_add;
static int threeway;
/* Ignore it, we already handled it */
break;
default:
- if (apply_verbosely)
+ if (state->apply_verbosely)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
apply = 0;
}
- if (apply_verbosely && applied_pos != pos) {
+ if (state->apply_verbosely && applied_pos != pos) {
int offset = applied_pos - pos;
if (state->apply_in_reverse)
offset = 0 - offset;
leading, trailing, applied_pos+1);
update_image(img, applied_pos, &preimage, &postimage);
} else {
- if (apply_verbosely)
+ if (state->apply_verbosely)
error(_("while searching for:\n%.*s"),
(int)(old - oldlines), oldlines);
}
prepare_symlink_changes(patch);
prepare_fn_table(patch);
while (patch) {
- if (apply_verbosely)
+ if (state->apply_verbosely)
say_patch_name(stderr,
_("Checking patch %s..."), patch);
err |= check_patch(state, patch);
create_file(patch);
}
-static int write_out_one_reject(struct patch *patch)
+static int write_out_one_reject(struct apply_state *state, struct patch *patch)
{
FILE *rej;
char namebuf[PATH_MAX];
}
if (!cnt) {
- if (apply_verbosely)
+ if (state->apply_verbosely)
say_patch_name(stderr,
_("Applied patch %s cleanly."), patch);
return 0;
return -1;
}
-static int write_out_results(struct patch *list)
+static int write_out_results(struct apply_state *state, struct patch *list)
{
int phase;
int errs = 0;
else {
write_out_one_result(l, phase);
if (phase == 1) {
- if (write_out_one_reject(l))
+ if (write_out_one_reject(state, l))
errs = 1;
if (l->conflicted_threeway) {
string_list_append(&cpath, l->new_name);
listp = &patch->next;
}
else {
- if (apply_verbosely)
+ if (state->apply_verbosely)
say_patch_name(stderr, _("Skipped patch '%s'."), patch);
free_patch(patch);
skipped_patch++;
!state->apply_with_reject)
exit(1);
- if (apply && write_out_results(list)) {
+ if (apply && write_out_results(state, list)) {
if (state->apply_with_reject)
exit(1);
/* with --3way, we still need to write the index out */
N_("leave the rejected hunks in corresponding *.rej files")),
OPT_BOOL(0, "allow-overlap", &allow_overlap,
N_("allow overlapping hunks")),
- OPT__VERBOSE(&apply_verbosely, N_("be verbose")),
+ OPT__VERBOSE(&state.apply_verbosely, N_("be verbose")),
OPT_BIT(0, "inaccurate-eof", &options,
N_("tolerate incorrectly detected missing new-line at the end of file"),
INACCURATE_EOF),
state.check_index = 1;
}
if (state.apply_with_reject)
- apply = apply_verbosely = 1;
+ apply = state.apply_verbosely = 1;
if (!force_apply && (diffstat || numstat || summary || state.check || fake_ancestor))
apply = 0;
if (state.check_index && is_not_gitdir)