return 0;
}
+static void verify_opt_compatible(const char *me, const char *base_opt, ...)
+{
+ const char *this_opt;
+ va_list ap;
+
+ va_start(ap, base_opt);
+ while ((this_opt = va_arg(ap, const char *))) {
+ if (va_arg(ap, int))
+ break;
+ }
+ va_end(ap);
+
+ if (this_opt)
+ die(_("%s: %s cannot be used with %s"), me, this_opt, base_opt);
+}
+
static void parse_args(int argc, const char **argv, struct replay_opts *opts)
{
const char * const * usage_str = revert_or_cherry_pick_usage(opts);
+ const char *me = action_name(opts);
int noop;
struct option options[] = {
OPT_BOOLEAN('n', "no-commit", &opts->no_commit, "don't automatically commit"),
if (opts->commit_argc < 2)
usage_with_options(usage_str, options);
+ if (opts->allow_ff)
+ verify_opt_compatible(me, "--ff",
+ "--signoff", opts->signoff,
+ "--no-commit", opts->no_commit,
+ "-x", opts->record_origin,
+ "--edit", opts->edit,
+ NULL);
opts->commit_argv = argv;
}
struct commit *commit;
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
- if (opts->allow_ff) {
- if (opts->signoff)
- die(_("cherry-pick --ff cannot be used with --signoff"));
- if (opts->no_commit)
- die(_("cherry-pick --ff cannot be used with --no-commit"));
- if (opts->record_origin)
- die(_("cherry-pick --ff cannot be used with -x"));
- if (opts->edit)
- die(_("cherry-pick --ff cannot be used with --edit"));
- }
-
+ if (opts->allow_ff)
+ assert(!(opts->signoff || opts->no_commit ||
+ opts->record_origin || opts->edit));
read_and_refresh_cache(opts);
prepare_revs(&revs, opts);