static void determine_replay_mode(struct rev_cmdline_info *cmd_info,
const char *onto_name,
- const char **advance_name,
+ char **advance_name,
struct commit **onto,
struct strset **update_refs)
{
*onto = peel_committish(*advance_name);
if (repo_dwim_ref(the_repository, *advance_name, strlen(*advance_name),
&oid, &fullname, 0) == 1) {
+ free(*advance_name);
*advance_name = fullname;
} else {
die(_("argument to --advance must be a reference"));
if (negative_refs_complete) {
struct hashmap_iter iter;
struct strmap_entry *entry;
+ const char *last_key = NULL;
if (rinfo.negative_refexprs == 0)
die(_("all positive revisions given must be references"));
/* Only one entry, but we have to loop to get it */
strset_for_each_entry(&rinfo.negative_refs,
&iter, entry) {
- *advance_name = entry->key;
+ last_key = entry->key;
}
+
+ free(*advance_name);
+ *advance_name = xstrdup_or_null(last_key);
} else { /* positive_refs_complete */
if (rinfo.negative_refexprs > 1)
die(_("cannot implicitly determine correct base for --onto"));
int cmd_replay(int argc, const char **argv, const char *prefix)
{
- const char *advance_name = NULL;
+ const char *advance_name_opt = NULL;
+ char *advance_name = NULL;
struct commit *onto = NULL;
const char *onto_name = NULL;
int contained = 0;
NULL
};
struct option replay_options[] = {
- OPT_STRING(0, "advance", &advance_name,
+ OPT_STRING(0, "advance", &advance_name_opt,
N_("branch"),
N_("make replay advance given branch")),
OPT_STRING(0, "onto", &onto_name,
argc = parse_options(argc, argv, prefix, replay_options, replay_usage,
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT);
- if (!onto_name && !advance_name) {
+ if (!onto_name && !advance_name_opt) {
error(_("option --onto or --advance is mandatory"));
usage_with_options(replay_usage, replay_options);
}
- if (advance_name && contained)
+ if (advance_name_opt && contained)
die(_("options '%s' and '%s' cannot be used together"),
"--advance", "--contained");
+ advance_name = xstrdup_or_null(advance_name_opt);
repo_init_revisions(the_repository, &revs, prefix);
cleanup:
release_revisions(&revs);
+ free(advance_name);
/* Return */
if (ret < 0)