Merge branch 'jc/index-v4'
[gitweb.git] / builtin / revert.c
index e4ed0239ca7cbc0f33f2cf02d6287e681ca535bf..82d1bf844b996d5d121169f244358964fd36fd19 100644 (file)
@@ -115,12 +115,16 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
                OPT_END(),
                OPT_END(),
                OPT_END(),
+               OPT_END(),
+               OPT_END(),
        };
 
        if (opts->action == REPLAY_PICK) {
                struct option cp_extra[] = {
                        OPT_BOOLEAN('x', NULL, &opts->record_origin, "append commit name"),
                        OPT_BOOLEAN(0, "ff", &opts->allow_ff, "allow fast-forward"),
+                       OPT_BOOLEAN(0, "allow-empty", &opts->allow_empty, "preserve initially empty commits"),
+                       OPT_BOOLEAN(0, "keep-redundant-commits", &opts->keep_redundant_commits, "keep redundant, empty commits"),
                        OPT_END(),
                };
                if (parse_options_concat(options, ARRAY_SIZE(options), cp_extra))
@@ -138,6 +142,10 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
                                "--abort", rollback,
                                NULL);
 
+       /* implies allow_empty */
+       if (opts->keep_redundant_commits)
+               opts->allow_empty = 1;
+
        /* Set the subcommand */
        if (remove_state)
                opts->subcommand = REPLAY_REMOVE_STATE;
@@ -182,12 +190,15 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
        if (opts->subcommand != REPLAY_NONE) {
                opts->revs = NULL;
        } else {
+               struct setup_revision_opt s_r_opt;
                opts->revs = xmalloc(sizeof(*opts->revs));
                init_revisions(opts->revs, NULL);
                opts->revs->no_walk = 1;
                if (argc < 2)
                        usage_with_options(usage_str, options);
-               argc = setup_revisions(argc, argv, opts->revs, NULL);
+               memset(&s_r_opt, 0, sizeof(s_r_opt));
+               s_r_opt.assume_dashdash = 1;
+               argc = setup_revisions(argc, argv, opts->revs, &s_r_opt);
        }
 
        if (argc > 1)