replay: use standard revision ranges
Instead of the fixed "<oldbase> <branch>" arguments, the replay command now accepts "<revision-range>..." arguments in a similar way as many other Git commands. This makes its interface more standard and more flexible. This also enables many revision related options accepted and eaten by setup_revisions(). If the replay command was a high level one or had a high level mode, it would make sense to restrict some of the possible options, like those generating non-contiguous history, as they could be confusing for most users. Also as the interface of the command is now mostly finalized, we can add more documentation and more testcases to make sure the command will continue to work as designed in the future. We only document the rev-list related options among all the revision related options that are now accepted, as the rev-list related ones are probably the most useful for now. Helped-by: Dragan Simic <dsimic@manjaro.org> Helped-by: Linus Arver <linusa@google.com> Co-authored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
81613be31e
commit
3916ec307e
@ -14,7 +14,6 @@
|
||||
#include "parse-options.h"
|
||||
#include "refs.h"
|
||||
#include "revision.h"
|
||||
#include "strvec.h"
|
||||
#include <oidset.h>
|
||||
#include <tree.h>
|
||||
|
||||
@ -118,16 +117,14 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
|
||||
struct commit *onto;
|
||||
const char *onto_name = NULL;
|
||||
struct commit *last_commit = NULL;
|
||||
struct strvec rev_walk_args = STRVEC_INIT;
|
||||
struct rev_info revs;
|
||||
struct commit *commit;
|
||||
struct merge_options merge_opt;
|
||||
struct merge_result result;
|
||||
struct strbuf branch_name = STRBUF_INIT;
|
||||
int ret = 0;
|
||||
|
||||
const char * const replay_usage[] = {
|
||||
N_("(EXPERIMENTAL!) git replay --onto <newbase> <oldbase> <branch>"),
|
||||
N_("(EXPERIMENTAL!) git replay --onto <newbase> <revision-range>..."),
|
||||
NULL
|
||||
};
|
||||
struct option replay_options[] = {
|
||||
@ -145,18 +142,10 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
|
||||
usage_with_options(replay_usage, replay_options);
|
||||
}
|
||||
|
||||
if (argc != 3) {
|
||||
error(_("bad number of arguments"));
|
||||
usage_with_options(replay_usage, replay_options);
|
||||
}
|
||||
|
||||
onto = peel_committish(onto_name);
|
||||
strbuf_addf(&branch_name, "refs/heads/%s", argv[2]);
|
||||
|
||||
repo_init_revisions(the_repository, &revs, prefix);
|
||||
|
||||
strvec_pushl(&rev_walk_args, "", argv[2], "--not", argv[1], NULL);
|
||||
|
||||
/*
|
||||
* Set desired values for rev walking options here. If they
|
||||
* are changed by some user specified option in setup_revisions()
|
||||
@ -171,8 +160,9 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
|
||||
revs.topo_order = 1;
|
||||
revs.simplify_history = 0;
|
||||
|
||||
if (setup_revisions(rev_walk_args.nr, rev_walk_args.v, &revs, NULL) > 1) {
|
||||
ret = error(_("unhandled options"));
|
||||
argc = setup_revisions(argc, argv, &revs, NULL);
|
||||
if (argc > 1) {
|
||||
ret = error(_("unrecognized argument: %s"), argv[1]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -205,8 +195,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
|
||||
revs.simplify_history = 0;
|
||||
}
|
||||
|
||||
strvec_clear(&rev_walk_args);
|
||||
|
||||
if (prepare_revision_walk(&revs) < 0) {
|
||||
ret = error(_("error preparing revisions"));
|
||||
goto cleanup;
|
||||
@ -248,7 +236,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
|
||||
ret = result.clean;
|
||||
|
||||
cleanup:
|
||||
strbuf_release(&branch_name);
|
||||
release_revisions(&revs);
|
||||
|
||||
/* Return */
|
||||
|
Reference in New Issue
Block a user