Skip to content

Commit 92d1502

Browse files
committed
Merge branch 'js/prepare-sequencer' into pu
Update of the sequencer codebase to make it reusable to reimplement "rebase -i" continues. * js/prepare-sequencer: (26 commits) SQUASH: nobody uses this function yet sequencer: mark all error messages for translation sequencer: start error messages consistently with lower case sequencer: quote filenames in error messages sequencer: mark action_name() for translation sequencer: remove overzealous assumption in rebase -i mode sequencer: refactor write_message() sequencer: left-trim lines read from the script sequencer: do not try to commit when there were merge conflicts sequencer: support cleaning up commit messages sequencer: support amending commits sequencer: allow editing the commit message on a case-by-case basis sequencer: introduce a helper to read files written by scripts sequencer: prepare for rebase -i's commit functionality sequencer: remember the onelines when parsing the todo file sequencer: refactor the code to obtain a short commit name sequencer: get rid of the subcommand field sequencer: avoid completely different messages for different actions sequencer: strip CR from the todo script sequencer: completely revamp the "todo" script parsing ...
2 parents d3bf6ba + 336b462 commit 92d1502

File tree

5 files changed

+496
-263
lines changed

5 files changed

+496
-263
lines changed

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void determine_whence(struct wt_status *s)
183183
whence = FROM_MERGE;
184184
else if (file_exists(git_path_cherry_pick_head())) {
185185
whence = FROM_CHERRY_PICK;
186-
if (file_exists(git_path(SEQ_DIR)))
186+
if (file_exists(git_path_seq_dir()))
187187
sequencer_in_use = 1;
188188
}
189189
else

builtin/revert.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)
7171
die(_("%s: %s cannot be used with %s"), me, this_opt, base_opt);
7272
}
7373

74-
static void parse_args(int argc, const char **argv, struct replay_opts *opts)
74+
static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
7575
{
7676
const char * const * usage_str = revert_or_cherry_pick_usage(opts);
7777
const char *me = action_name(opts);
@@ -115,25 +115,15 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
115115
if (opts->keep_redundant_commits)
116116
opts->allow_empty = 1;
117117

118-
/* Set the subcommand */
119-
if (cmd == 'q')
120-
opts->subcommand = REPLAY_REMOVE_STATE;
121-
else if (cmd == 'c')
122-
opts->subcommand = REPLAY_CONTINUE;
123-
else if (cmd == 'a')
124-
opts->subcommand = REPLAY_ROLLBACK;
125-
else
126-
opts->subcommand = REPLAY_NONE;
127-
128118
/* Check for incompatible command line arguments */
129-
if (opts->subcommand != REPLAY_NONE) {
119+
if (cmd) {
130120
char *this_operation;
131-
if (opts->subcommand == REPLAY_REMOVE_STATE)
121+
if (cmd == 'q')
132122
this_operation = "--quit";
133-
else if (opts->subcommand == REPLAY_CONTINUE)
123+
else if (cmd == 'c')
134124
this_operation = "--continue";
135125
else {
136-
assert(opts->subcommand == REPLAY_ROLLBACK);
126+
assert(cmd == 'a');
137127
this_operation = "--abort";
138128
}
139129

@@ -156,7 +146,7 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
156146
"--edit", opts->edit,
157147
NULL);
158148

159-
if (opts->subcommand != REPLAY_NONE) {
149+
if (cmd) {
160150
opts->revs = NULL;
161151
} else {
162152
struct setup_revision_opt s_r_opt;
@@ -174,35 +164,45 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
174164

175165
if (argc > 1)
176166
usage_with_options(usage_str, options);
167+
168+
/* These option values will be free()d */
169+
if (opts->gpg_sign)
170+
opts->gpg_sign = xstrdup(opts->gpg_sign);
171+
if (opts->strategy)
172+
opts->strategy = xstrdup(opts->strategy);
173+
174+
if (cmd == 'q')
175+
return sequencer_remove_state(opts);
176+
if (cmd == 'c')
177+
return sequencer_continue(opts);
178+
if (cmd == 'a')
179+
return sequencer_rollback(opts);
180+
return sequencer_pick_revisions(opts);
177181
}
178182

179183
int cmd_revert(int argc, const char **argv, const char *prefix)
180184
{
181-
struct replay_opts opts;
185+
struct replay_opts opts = REPLAY_OPTS_INIT;
182186
int res;
183187

184-
memset(&opts, 0, sizeof(opts));
185188
if (isatty(0))
186189
opts.edit = 1;
187190
opts.action = REPLAY_REVERT;
188191
git_config(git_default_config, NULL);
189-
parse_args(argc, argv, &opts);
190-
res = sequencer_pick_revisions(&opts);
192+
res = run_sequencer(argc, argv, &opts);
191193
if (res < 0)
192194
die(_("revert failed"));
193195
return res;
194196
}
195197

196198
int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
197199
{
198-
struct replay_opts opts;
200+
struct replay_opts opts = REPLAY_OPTS_INIT;
199201
int res;
200202

201-
memset(&opts, 0, sizeof(opts));
202203
opts.action = REPLAY_PICK;
203204
git_config(git_default_config, NULL);
204-
parse_args(argc, argv, &opts);
205-
res = sequencer_pick_revisions(&opts);
205+
res = run_sequencer(argc, argv, &opts);
206206
if (res < 0)
207207
die(_("cherry-pick failed"));
208208
return res;

0 commit comments

Comments
 (0)