summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2017-01-23 23:52:21 +0100
committerJunio C Hamano <gitster@pobox.com>2017-01-25 14:49:32 -0800
commitb614cad4fcacd4728defd86d84da85e374aef4a9 (patch)
tree53531df9db2bf5975dedb3bc1e2011d9e44df6a6 /sequencer.c
parent7581b5118a715b9e882ea156fbe6d81d9180e911 (diff)
downloadgit-gb/cherry-pick-skip.tar.gz
sequencer: allow to --skip current commitgb/cherry-pick-skip
If a sequencing gets interrupted (by a conflict or an empty commit or whatever), the user can now opt to just skip it passing the `--skip` command line option, which acts like a `--continue`, except that the current commit gets skipped. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/sequencer.c b/sequencer.c
index d2d9aced19..684b341e14 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1359,21 +1359,45 @@ static int continue_single_pick(void)
return run_command_v_opt(argv, RUN_GIT_CMD);
}
-int sequencer_continue(struct replay_opts *opts)
+/*
+ * Continue the sequencing, after either committing
+ * (cmd == 'c') or skipping (cmd == 's') the current
+ * commit.
+ */
+int sequencer_continue(struct replay_opts *opts, char cmd)
{
struct todo_list todo_list = TODO_LIST_INIT;
- int res;
+ int single, res;
if (read_and_refresh_cache(opts))
return -1;
- if (!file_exists(get_todo_path(opts)))
- return continue_single_pick();
+ if (!file_exists(get_todo_path(opts))) {
+ if (cmd == 'c') {
+ return continue_single_pick();
+ } else {
+ assert(cmd == 's');
+ /* Skipping the only commit is equivalent to an abort */
+ return sequencer_rollback(opts);
+ }
+ }
if (read_populate_opts(opts))
return -1;
if ((res = read_populate_todo(&todo_list, opts)))
goto release_todo_list;
+ /* If we were asked to skip this commit, rollback
+ * and continue with the next */
+ if (cmd == 's') {
+ if ((res = rollback_single_pick()))
+ goto release_todo_list;
+ discard_cache();
+ if ((res = read_cache()) < 0)
+ goto release_todo_list;
+ printf("index unchanged: %d\n", is_index_unchanged());
+ goto skip_this_commit;
+ }
+
/* check if there is something to commit */
res = is_index_unchanged();
if (res < 0)