sequencer: use static initializers for replay_opts

This change is not completely faithful: instead of initializing all fields
to 0, we choose to initialize command and subcommand to -1 (instead of
defaulting to REPLAY_REVERT and REPLAY_NONE, respectively). Practically,
it makes no difference at all, but future-proofs the code to require
explicit assignments for both fields.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Johannes Schindelin 2016-10-14 15:15:56 +02:00 committed by Junio C Hamano
parent a23ca1b8dc
commit ee624c0d3f
2 changed files with 3 additions and 4 deletions

View File

@ -178,10 +178,9 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)


int cmd_revert(int argc, const char **argv, const char *prefix) int cmd_revert(int argc, const char **argv, const char *prefix)
{ {
struct replay_opts opts; struct replay_opts opts = REPLAY_OPTS_INIT;
int res; int res;


memset(&opts, 0, sizeof(opts));
if (isatty(0)) if (isatty(0))
opts.edit = 1; opts.edit = 1;
opts.action = REPLAY_REVERT; opts.action = REPLAY_REVERT;
@ -195,10 +194,9 @@ int cmd_revert(int argc, const char **argv, const char *prefix)


int cmd_cherry_pick(int argc, const char **argv, const char *prefix) int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
{ {
struct replay_opts opts; struct replay_opts opts = REPLAY_OPTS_INIT;
int res; int res;


memset(&opts, 0, sizeof(opts));
opts.action = REPLAY_PICK; opts.action = REPLAY_PICK;
git_config(git_default_config, NULL); git_config(git_default_config, NULL);
parse_args(argc, argv, &opts); parse_args(argc, argv, &opts);

View File

@ -47,6 +47,7 @@ struct replay_opts {
/* Only used by REPLAY_NONE */ /* Only used by REPLAY_NONE */
struct rev_info *revs; struct rev_info *revs;
}; };
#define REPLAY_OPTS_INIT { -1, -1 }


int sequencer_pick_revisions(struct replay_opts *opts); int sequencer_pick_revisions(struct replay_opts *opts);