int check_index; /* preimage must match the indexed version */
/* These boolean parameters control how the apply is done */
int check_index; /* preimage must match the indexed version */
/* These boolean parameters control how the apply is done */
static int apply_with_reject;
static int apply_verbosely;
static int allow_overlap;
static int apply_with_reject;
static int apply_verbosely;
static int allow_overlap;
* between a "---" that is part of a patch, and a "---" that starts
* the next patch is to look at the line counts..
*/
* between a "---" that is part of a patch, and a "---" that starts
* the next patch is to look at the line counts..
*/
-static int parse_fragment(const char *line, unsigned long size,
- struct patch *patch, struct fragment *fragment)
+static int parse_fragment(struct apply_state *state,
+ const char *line,
+ unsigned long size,
+ struct patch *patch,
+ struct fragment *fragment)
ws_error_action == correct_ws_error)
check_whitespace(line, len, patch->ws_rule);
break;
case '-':
ws_error_action == correct_ws_error)
check_whitespace(line, len, patch->ws_rule);
break;
case '-':
ws_error_action != nowarn_ws_error)
check_whitespace(line, len, patch->ws_rule);
deleted++;
ws_error_action != nowarn_ws_error)
check_whitespace(line, len, patch->ws_rule);
deleted++;
ws_error_action != nowarn_ws_error)
check_whitespace(line, len, patch->ws_rule);
added++;
ws_error_action != nowarn_ws_error)
check_whitespace(line, len, patch->ws_rule);
added++;
* The (fragment->patch, fragment->size) pair points into the memory given
* by the caller, not a copy, when we return.
*/
* The (fragment->patch, fragment->size) pair points into the memory given
* by the caller, not a copy, when we return.
*/
{
unsigned long offset = 0;
unsigned long oldlines = 0, newlines = 0, context = 0;
{
unsigned long offset = 0;
unsigned long oldlines = 0, newlines = 0, context = 0;
fragment = xcalloc(1, sizeof(*fragment));
fragment->linenr = state_linenr;
fragment = xcalloc(1, sizeof(*fragment));
fragment->linenr = state_linenr;
- len = parse_fragment(line, size, patch, fragment);
+ len = parse_fragment(state, line, size, patch, fragment);
- patchsize = parse_single_patch(buffer + offset + hdrsize,
- size - offset - hdrsize, patch);
+ patchsize = parse_single_patch(state,
+ buffer + offset + hdrsize,
+ size - offset - hdrsize,
+ patch);
if (!fragment->next)
return error("cannot reverse-apply a binary patch "
"without the reverse hunk to '%s'",
if (!fragment->next)
return error("cannot reverse-apply a binary patch "
"without the reverse hunk to '%s'",
* but the preimage prepared by the caller in "img" is freed here
* or in the helper function apply_binary_fragment() this calls.
*/
* but the preimage prepared by the caller in "img" is freed here
* or in the helper function apply_binary_fragment() this calls.
*/
* apply the patch data to it, which is stored
* in the patch->fragments->{patch,size}.
*/
* apply the patch data to it, which is stored
* in the patch->fragments->{patch,size}.
*/
{ OPTION_CALLBACK, 0, "ignore-whitespace", NULL, NULL,
N_("ignore changes in whitespace when finding context"),
PARSE_OPT_NOARG, option_parse_space_change },
{ OPTION_CALLBACK, 0, "ignore-whitespace", NULL, NULL,
N_("ignore changes in whitespace when finding context"),
PARSE_OPT_NOARG, option_parse_space_change },
- OPT_BOOL('R', "reverse", &apply_in_reverse,
+ OPT_BOOL('R', "reverse", &state.apply_in_reverse,
N_("apply the patch in reverse")),
OPT_BOOL(0, "unidiff-zero", &state.unidiff_zero,
N_("don't expect at least one line of context")),
N_("apply the patch in reverse")),
OPT_BOOL(0, "unidiff-zero", &state.unidiff_zero,
N_("don't expect at least one line of context")),