diff --git a/apply.c b/apply.c index c022af53a2..5a6ca10a7a 100644 --- a/apply.c +++ b/apply.c @@ -75,12 +75,10 @@ static int parse_ignorewhitespace_option(struct apply_state *state, } int init_apply_state(struct apply_state *state, - const char *prefix, - struct lock_file *lock_file) + const char *prefix) { memset(state, 0, sizeof(*state)); state->prefix = prefix; - state->lock_file = lock_file; state->newfd = -1; state->apply = 1; state->line_termination = '\n'; @@ -146,8 +144,6 @@ int check_apply_state(struct apply_state *state, int force_apply) } if (state->check_index) state->unsafe_paths = 0; - if (!state->lock_file) - return error("BUG: state->lock_file should not be NULL"); if (state->apply_verbosity <= verbosity_silent) { state->saved_error_routine = get_error_routine(); @@ -4711,11 +4707,11 @@ static int apply_patch(struct apply_state *state, state->update_index = state->check_index && state->apply; if (state->update_index && state->newfd < 0) { if (state->index_file) - state->newfd = hold_lock_file_for_update(state->lock_file, + state->newfd = hold_lock_file_for_update(&state->lock_file, state->index_file, LOCK_DIE_ON_ERROR); else - state->newfd = hold_locked_index(state->lock_file, LOCK_DIE_ON_ERROR); + state->newfd = hold_locked_index(&state->lock_file, LOCK_DIE_ON_ERROR); } if (state->check_index && read_apply_cache(state) < 0) { @@ -4911,7 +4907,7 @@ int apply_all_patches(struct apply_state *state, } if (state->update_index) { - res = write_locked_index(&the_index, state->lock_file, COMMIT_LOCK); + res = write_locked_index(&the_index, &state->lock_file, COMMIT_LOCK); if (res) { error(_("Unable to write new index file")); res = -128; @@ -4924,7 +4920,7 @@ int apply_all_patches(struct apply_state *state, end: if (state->newfd >= 0) { - rollback_lock_file(state->lock_file); + rollback_lock_file(&state->lock_file); state->newfd = -1; } diff --git a/apply.h b/apply.h index d9b3957703..cf00cda171 100644 --- a/apply.h +++ b/apply.h @@ -37,7 +37,7 @@ struct apply_state { const char *prefix; /* These are lock_file related */ - struct lock_file *lock_file; + struct lock_file lock_file; int newfd; /* These control what gets looked at and modified */ @@ -116,8 +116,7 @@ extern int apply_parse_options(int argc, const char **argv, int *force_apply, int *options, const char * const *apply_usage); extern int init_apply_state(struct apply_state *state, - const char *prefix, - struct lock_file *lock_file); + const char *prefix); extern void clear_apply_state(struct apply_state *state); extern int check_apply_state(struct apply_state *state, int force_apply); diff --git a/builtin/am.c b/builtin/am.c index 4e16fd428f..40968428dd 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1488,11 +1488,10 @@ static int run_apply(const struct am_state *state, const char *index_file) struct argv_array apply_opts = ARGV_ARRAY_INIT; struct apply_state apply_state; int res, opts_left; - static struct lock_file lock_file; int force_apply = 0; int options = 0; - if (init_apply_state(&apply_state, NULL, &lock_file)) + if (init_apply_state(&apply_state, NULL)) die("BUG: init_apply_state() failed"); argv_array_push(&apply_opts, "apply"); diff --git a/builtin/apply.c b/builtin/apply.c index 81b9a61c37..48d3989331 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -9,8 +9,6 @@ static const char * const apply_usage[] = { NULL }; -static struct lock_file lock_file; - int cmd_apply(int argc, const char **argv, const char *prefix) { int force_apply = 0; @@ -18,7 +16,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix) int ret; struct apply_state state; - if (init_apply_state(&state, prefix, &lock_file)) + if (init_apply_state(&state, prefix)) exit(128); argc = apply_parse_options(argc, argv,