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>
Johannes Schindelin committed
Oct 14, 2016 at 15:15 UTC
ee624c0d3ff54e86a44cddf1d4ea6278b7a4f65c
2 files changed
+3
-4
builtin/revert.c
+2
-4
@@ -178,10 +178,9 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
178
179
int cmd_revert(int argc, const char **argv, const char *prefix)
180
{
181
- struct replay_opts opts;
181
+ struct replay_opts opts = REPLAY_OPTS_INIT;
182
int res;
183
184
- memset(&opts, 0, sizeof(opts));
184
if (isatty(0))
185
opts.edit = 1;
186
opts.action = REPLAY_REVERT;
@@ -195,10 +194,9 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
194
195
int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
196
{
198
- struct replay_opts opts;
197
+ struct replay_opts opts = REPLAY_OPTS_INIT;
198
int res;
199
201
- memset(&opts, 0, sizeof(opts));
200
opts.action = REPLAY_PICK;
201
git_config(git_default_config, NULL);
202
parse_args(argc, argv, &opts);
sequencer.h
+1
@@ -47,6 +47,7 @@ struct replay_opts {
47
/* Only used by REPLAY_NONE */
48
struct rev_info *revs;
49
};
50
+#define REPLAY_OPTS_INIT { -1, -1 }
51
52
int sequencer_pick_revisions(struct replay_opts *opts);
53