* [PATCH 0/1] rebase -i: introduce the 'break' command @ 2018-10-03 15:00 Johannes Schindelin via GitGitGadget 2018-10-03 15:00 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget 2018-10-10 8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget 0 siblings, 2 replies; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-03 15:00 UTC (permalink / raw) To: git; +Cc: Stefan Beller, Junio C Hamano Stefan asked a while back [https://public-inbox.org/git/20180118183618.39853-3-sbeller@google.com/] for a todo command in interactive rebases that would essentially perform the "stop" part of the edit command, but without the "pick" part: interrupt the interactive rebase, with exit code 0, letting the user do things and stuff and look around, with the idea of continuing the rebase later (using git rebase --continue). This patch introduces that, based on ag/rebase-i-in-c. Johannes Schindelin (1): rebase -i: introduce the 'break' command rebase-interactive.c | 1 + sequencer.c | 7 ++++++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) base-commit: b3fe2e1f8cbf5522e7ba49db76bff38f204e2093 Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-43%2Fdscho%2Frebase-i-break-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-43/dscho/rebase-i-break-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/43 -- gitgitgadget ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 1/1] rebase -i: introduce the 'break' command 2018-10-03 15:00 [PATCH 0/1] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget @ 2018-10-03 15:00 ` Johannes Schindelin via GitGitGadget 2018-10-05 8:15 ` Junio C Hamano 2018-10-10 8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget 1 sibling, 1 reply; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-03 15:00 UTC (permalink / raw) To: git; +Cc: Stefan Beller, Junio C Hamano, Johannes Schindelin From: Johannes Schindelin <johannes.schindelin@gmx.de> The 'edit' command can be used to cherry-pick a commit and then immediately drop out of the interactive rebase, with exit code 0, to let the user amend the commit, or test it, or look around. Sometimes this functionality would come in handy *without* cherry-picking a commit, e.g. to interrupt the interactive rebase even before cherry-picking a commit, or immediately after an 'exec' or a 'merge'. This commit introduces that functionality, as the spanking new 'break' command. Suggested-by: Stefan Beller <sbeller@google.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- rebase-interactive.c | 1 + sequencer.c | 7 ++++++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/rebase-interactive.c b/rebase-interactive.c index 0f4119cbae..78f3263fc1 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -14,6 +14,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty, "s, squash <commit> = use commit, but meld into previous commit\n" "f, fixup <commit> = like \"squash\", but discard this commit's log message\n" "x, exec <command> = run command (the rest of the line) using shell\n" +"b, break = stop here (continue rebase later with 'git rebase --continue')\n" "d, drop <commit> = remove commit\n" "l, label <label> = label current HEAD with a name\n" "t, reset <label> = reset HEAD to a label\n" diff --git a/sequencer.c b/sequencer.c index 8dd6db5a01..b209f8af46 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1416,6 +1416,7 @@ enum todo_command { TODO_SQUASH, /* commands that do something else than handling a single commit */ TODO_EXEC, + TODO_BREAK, TODO_LABEL, TODO_RESET, TODO_MERGE, @@ -1437,6 +1438,7 @@ static struct { { 'f', "fixup" }, { 's', "squash" }, { 'x', "exec" }, + { 'b', "break" }, { 'l', "label" }, { 't', "reset" }, { 'm', "merge" }, @@ -1964,7 +1966,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) padding = strspn(bol, " \t"); bol += padding; - if (item->command == TODO_NOOP) { + if (item->command == TODO_NOOP || item->command == TODO_BREAK) { if (bol != eol) return error(_("%s does not accept arguments: '%s'"), command_to_string(item->command), bol); @@ -3293,6 +3295,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) unlink(rebase_path_stopped_sha()); unlink(rebase_path_amend()); delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); + + if (item->command == TODO_BREAK) + break; } if (item->command <= TODO_SQUASH) { if (is_rebase_i(opts)) diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 25a77ee5cb..584604ee63 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -49,7 +49,7 @@ set_fake_editor () { case $line in squash|fixup|edit|reword|drop) action="$line";; - exec*) + exec*|break) echo "$line" | sed 's/_/ /g' >> "$1";; "#") echo '# comment' >> "$1";; diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index c145dbac38..185a491089 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -239,5 +239,14 @@ test_rerere_autoupdate -m GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR test_rerere_autoupdate -i test_rerere_autoupdate --preserve-merges +unset GIT_SEQUENCE_EDITOR + +test_expect_success 'the todo command "break" works' ' + rm -f execed && + FAKE_LINES="break exec_>execed" git rebase -i HEAD && + test_path_is_missing execed && + git rebase --continue && + test_path_is_file execed +' test_done -- gitgitgadget ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 1/1] rebase -i: introduce the 'break' command 2018-10-03 15:00 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget @ 2018-10-05 8:15 ` Junio C Hamano 2018-10-05 8:36 ` Jacob Keller 2018-10-05 15:36 ` Johannes Schindelin 0 siblings, 2 replies; 27+ messages in thread From: Junio C Hamano @ 2018-10-05 8:15 UTC (permalink / raw) To: Johannes Schindelin via GitGitGadget Cc: git, Stefan Beller, Johannes Schindelin "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > The 'edit' command can be used to cherry-pick a commit and then > immediately drop out of the interactive rebase, with exit code 0, to let > the user amend the commit, or test it, or look around. > > Sometimes this functionality would come in handy *without* > cherry-picking a commit, e.g. to interrupt the interactive rebase even > before cherry-picking a commit, or immediately after an 'exec' or a > 'merge'. > > This commit introduces that functionality, as the spanking new 'break' command. > > Suggested-by: Stefan Beller <sbeller@google.com> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- If one wants to emulate this with the versions of Git that are currently deployed, would it be sufficient to insert "exec false" instead of "break"? The reason I am asking is *not* to imply that we do not need this new feature. It is because I vaguely recall seeing a request to add 'pause' to the insn set and "exec false" was mentioned as a more general alternative long time ago. I am trying to see if this is a recurring request/wish, because it would reinforce that this new feature would be a good addition if that is the case. I suspect that "exec false" would give a message that looks like a complaint ("'false' failed so we are giving you control back to fix things" or something like that), and having a dedicated way to pause the execution without alarming the user is a good idea. I think the earlier request asked for 'pause' (I didn't dig the list archive very carefully, though), and 'stop' may also be a possible verb, but I tend to agree with this patch that 'break' is probably the best choice, simply because it begins with 'b' in the abbreviated form, a letter that is not yet used by others (unlike 'pause' or 'stop' that would want 'p' and 's' that are already taken).. Here is a tangent, but I think the description of "-x <cmd>" in "git rebase --continue" should mention that a failing command would interrupt the sequencer. That fact about "exec" command is given much later in the last part of the "interactive mode" section of the manual, so technically our docs are not being incomplete, but the current description is not helpful to those who are looking for substring "exec" from the beginning of the documentation to find out if the exit status of the command affects the way commits are replayed (which is what I was doing when imagining how users would emulate this feature with deployed versions of Git). Perhaps something as simple as this... Documentation/git-rebase.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 0e20a66e73..0fc5a851b5 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). --exec <cmd>:: Append "exec <cmd>" after each line creating a commit in the final history. <cmd> will be interpreted as one or more shell - commands. + commands, and interrupts the rebase session when it exits with + non-zero status. + You may execute several commands by either using one instance of `--exec` with several commands: Also, it seems that this has some interaction with the topics in flight; the added test does pass when queued on top of 'master', but fails when merged to 'pu'. I didn't look into the details as I am not fully online yet. Thanks. ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 1/1] rebase -i: introduce the 'break' command 2018-10-05 8:15 ` Junio C Hamano @ 2018-10-05 8:36 ` Jacob Keller 2018-10-05 15:36 ` Johannes Schindelin 1 sibling, 0 replies; 27+ messages in thread From: Jacob Keller @ 2018-10-05 8:36 UTC (permalink / raw) To: Junio C Hamano Cc: gitgitgadget, Git mailing list, Stefan Beller, Johannes Schindelin On Fri, Oct 5, 2018 at 1:17 AM Junio C Hamano <gitster@pobox.com> wrote: > If one wants to emulate this with the versions of Git that are > currently deployed, would it be sufficient to insert "exec false" > instead of "break"? > > The reason I am asking is *not* to imply that we do not need this > new feature. It is because I vaguely recall seeing a request to add > 'pause' to the insn set and "exec false" was mentioned as a more > general alternative long time ago. I am trying to see if this is a > recurring request/wish, because it would reinforce that this new > feature would be a good addition if that is the case. > > I suspect that "exec false" would give a message that looks like a > complaint ("'false' failed so we are giving you control back to fix > things" or something like that), and having a dedicated way to pause > the execution without alarming the user is a good idea. > > I think the earlier request asked for 'pause' (I didn't dig the list > archive very carefully, though), and 'stop' may also be a possible > verb, but I tend to agree with this patch that 'break' is probably > the best choice, simply because it begins with 'b' in the > abbreviated form, a letter that is not yet used by others (unlike > 'pause' or 'stop' that would want 'p' and 's' that are already > taken).. > Yea. I use "exec false" all the time for this purpose, but it's a bit confusing, and it does cause rebase to indicate that a command failed. I think adding a builtin command to do this is a good idea, and I think break is a reasonable verb, (especially considering the shorthand "b"). Regards, Jake ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/1] rebase -i: introduce the 'break' command 2018-10-05 8:15 ` Junio C Hamano 2018-10-05 8:36 ` Jacob Keller @ 2018-10-05 15:36 ` Johannes Schindelin 2018-10-09 3:59 ` Junio C Hamano 1 sibling, 1 reply; 27+ messages in thread From: Johannes Schindelin @ 2018-10-05 15:36 UTC (permalink / raw) To: Junio C Hamano; +Cc: Johannes Schindelin via GitGitGadget, git, Stefan Beller Hi Junio, On Fri, 5 Oct 2018, Junio C Hamano wrote: > "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> > writes: > > > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > > > The 'edit' command can be used to cherry-pick a commit and then > > immediately drop out of the interactive rebase, with exit code 0, to let > > the user amend the commit, or test it, or look around. > > > > Sometimes this functionality would come in handy *without* > > cherry-picking a commit, e.g. to interrupt the interactive rebase even > > before cherry-picking a commit, or immediately after an 'exec' or a > > 'merge'. > > > > This commit introduces that functionality, as the spanking new 'break' command. > > > > Suggested-by: Stefan Beller <sbeller@google.com> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > --- > > If one wants to emulate this with the versions of Git that are > currently deployed, would it be sufficient to insert "exec false" > instead of "break"? There is one crucial difference: the exit code. If you are scripting around `git rebase -i` (and I do, heavily), then that is quite a difference: who's to say that the rebase "failed" because of that `exec false`, or if it failed another `exec` unexpectedly? > The reason I am asking is *not* to imply that we do not need this > new feature. It is because I vaguely recall seeing a request to add > 'pause' to the insn set and "exec false" was mentioned as a more > general alternative long time ago. I am trying to see if this is a > recurring request/wish, because it would reinforce that this new > feature would be a good addition if that is the case. > > I suspect that "exec false" would give a message that looks like a > complaint ("'false' failed so we are giving you control back to fix > things" or something like that), and having a dedicated way to pause > the execution without alarming the user is a good idea. > > I think the earlier request asked for 'pause' (I didn't dig the list > archive very carefully, though), No need to: I mentioned it in the cover letter. Here is the link again, for your convenience: https://public-inbox.org/git/20180118183618.39853-3-sbeller@google.com/ > and 'stop' may also be a possible verb, but I tend to agree with this > patch that 'break' is probably the best choice, simply because it begins > with 'b' in the abbreviated form, a letter that is not yet used by > others (unlike 'pause' or 'stop' that would want 'p' and 's' that are > already taken).. > > Here is a tangent, but I think the description of "-x <cmd>" in "git > rebase --continue" should mention that a failing command would > interrupt the sequencer. That fact about "exec" command is given > much later in the last part of the "interactive mode" section of the > manual, so technically our docs are not being incomplete, but the > current description is not helpful to those who are looking for > substring "exec" from the beginning of the documentation to find out > if the exit status of the command affects the way commits are > replayed (which is what I was doing when imagining how users would > emulate this feature with deployed versions of Git). > > Perhaps something as simple as this... > > Documentation/git-rebase.txt | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > index 0e20a66e73..0fc5a851b5 100644 > --- a/Documentation/git-rebase.txt > +++ b/Documentation/git-rebase.txt > @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). > --exec <cmd>:: > Append "exec <cmd>" after each line creating a commit in the > final history. <cmd> will be interpreted as one or more shell > - commands. > + commands, and interrupts the rebase session when it exits with > + non-zero status. Good initial version. I would like it to be a bit more precise about who exits with what status. How about this: + commands. Any command that fails will interrupt the rebase, + with exit code 1. > + > You may execute several commands by either using one instance of `--exec` > with several commands: > > > Also, it seems that this has some interaction with the topics in > flight; the added test does pass when queued on top of 'master', but > fails when merged to 'pu'. I didn't look into the details as I am > not fully online yet. I had a similar issue in a preliminary revision, and had to unset GIT_EDITOR to fix it. Probably the culprit here is the same; I could imagine that core.editor was set by another topic. [... clicketiclick, debug debug debug, 1.5h later...] Actually, this is not the problem. The problem is that the interactive rebase exits with status 0 but does not leave a `stopped-sha` file behind, and the builtin rebase mistakes that for a sign that it can clean up the state dir. However, we definitely do not want to leave that file, because it indicates a fixup or squash with merge conflicts was left behind. Taking a step back, it appears that we do a whole lot of work for nothing in the case of the interactive rebase: it cleans up the state directory itself already, and takes care of the autostash support, too. So I will apply this fixup js/rebase-in-c-5.5-work-with-rebase-i-in-c: -- snip -- fixup! builtin rebase: prepare for builtin rebase -i The original patch worked, but overlooked the fact that `git rebase--interactive` really wants to take care of finishing the rebase itself. While it was not harmful to try again, there was no directory to work with, so no harm was done. Except in the case that an `edit` command was processed, in which case we used the `stopped-sha` file as tell-tale that we should not remove the state directory. However, with the `break` command we do not have such a tell-tale. But then, we don't really need one: the built-in `rebase--interactive` takes care of clean-up itself. So we can just skip it in the built-in rebase. While at it, remove the `case` arm for the interactive rebase that is now skipped in favor of the short-cut to the built-in rebase. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- builtin/rebase.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 99fd5d4017..2ca5fa1d74 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -410,6 +410,7 @@ static int run_specific_rebase(struct rebase_options *opts) argv_array_push(&child.args, "--signoff"); status = run_command(&child); + goto finished_rebase; } @@ -475,10 +476,6 @@ static int run_specific_rebase(struct rebase_options *opts) backend = "git-rebase--am"; backend_func = "git_rebase__am"; break; - case REBASE_INTERACTIVE: - backend = "git-rebase--interactive"; - backend_func = "git_rebase__interactive"; - break; case REBASE_MERGE: backend = "git-rebase--merge"; backend_func = "git_rebase__merge"; @@ -501,6 +498,8 @@ static int run_specific_rebase(struct rebase_options *opts) finished_rebase: if (opts->dont_finish_rebase) ; /* do nothing */ + else if (opts->type == REBASE_INTERACTIVE) + ; /* interactive rebase cleans up after itself */ else if (status == 0) { if (!file_exists(state_dir_path("stopped-sha", opts))) finish_rebase(opts); -- snap -- This fix-up seems to unbreak the `break` test case (pun intended)... Ciao, Dscho -- 2.19.0.windows.1.30.g502e856705 > > Thanks. > ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 1/1] rebase -i: introduce the 'break' command 2018-10-05 15:36 ` Johannes Schindelin @ 2018-10-09 3:59 ` Junio C Hamano 2018-10-09 5:27 ` Junio C Hamano 0 siblings, 1 reply; 27+ messages in thread From: Junio C Hamano @ 2018-10-09 3:59 UTC (permalink / raw) To: Johannes Schindelin Cc: Johannes Schindelin via GitGitGadget, git, Stefan Beller Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > Hi Junio, > > On Fri, 5 Oct 2018, Junio C Hamano wrote: > >> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> >> writes: >> >> > From: Johannes Schindelin <johannes.schindelin@gmx.de> >> > >> > The 'edit' command can be used to cherry-pick a commit and then >> > immediately drop out of the interactive rebase, with exit code 0, to let >> > the user amend the commit, or test it, or look around. >> ... >> If one wants to emulate this with the versions of Git that are >> currently deployed, would it be sufficient to insert "exec false" >> instead of "break"? > > There is one crucial difference: the exit code. OK, and it was good that you explicitly said "with exit code 0" in the log message. Together with the idea to update the doc I floated earlier, this probably is worth documenting, too. >> I think the earlier request asked for 'pause' (I didn't dig the list >> archive very carefully, though), > > No need to: I mentioned it in the cover letter. Here is the link again, > for your convenience: > https://public-inbox.org/git/20180118183618.39853-3-sbeller@google.com/ No, you misunderstood. I knew what message in the immediate past triggered this patch and that wasn't what I "could have dug for but didn't". "The earlier request" I meant was another one I recall that was made long time ago---that was what I "could have dug for but didn't". > Good initial version. I would like it to be a bit more precise about who > exits with what status. How about this: Sounds good. It is likely that I'll either forget or will continue to be too busy to pick textual pieces and assemble together myself, so I'll leave it as a left over bit for somebody reading from the sideline to send in a finished version if they care deeply enough ;-) Thanks. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/1] rebase -i: introduce the 'break' command 2018-10-09 3:59 ` Junio C Hamano @ 2018-10-09 5:27 ` Junio C Hamano 0 siblings, 0 replies; 27+ messages in thread From: Junio C Hamano @ 2018-10-09 5:27 UTC (permalink / raw) To: Johannes Schindelin Cc: Johannes Schindelin via GitGitGadget, git, Stefan Beller Junio C Hamano <gitster@pobox.com> writes: >> There is one crucial difference: the exit code. > > OK, and it was good that you explicitly said "with exit code 0" in > the log message. Together with the idea to update the doc I floated > earlier, this probably is worth documenting, too. Heh, I am becoming sloppy in reviewing. The patch does not even update any doc. It is not a reason to reject the change (the change looks reasonably simple and reviewers and those who have to look at the code to build upon it would understand it in the current shape), but it is a blocker for the change to be merged to 'next' and down. ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 0/2] rebase -i: introduce the 'break' command 2018-10-03 15:00 [PATCH 0/1] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget 2018-10-03 15:00 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget @ 2018-10-10 8:53 ` Johannes Schindelin via GitGitGadget 2018-10-10 8:53 ` [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget ` (2 more replies) 1 sibling, 3 replies; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-10 8:53 UTC (permalink / raw) To: git; +Cc: Stefan Beller, Junio C Hamano Stefan asked a while back [https://public-inbox.org/git/20180118183618.39853-3-sbeller@google.com/] for a todo command in interactive rebases that would essentially perform the "stop" part of the edit command, but without the "pick" part: interrupt the interactive rebase, with exit code 0, letting the user do things and stuff and look around, with the idea of continuing the rebase later (using git rebase --continue). This patch introduces that, based on ag/rebase-i-in-c. Changes since v1: * Wrapped the commit message correctly. * Added a preparatory patch to mention what happens in case an exec fails. * Mentioned the break command in the git-rebase(1) documentation. Johannes Schindelin (2): rebase -i: clarify what happens on a failed `exec` rebase -i: introduce the 'break' command Documentation/git-rebase.txt | 6 +++++- rebase-interactive.c | 1 + sequencer.c | 7 ++++++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 9 +++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) base-commit: 34b47315d9721a576b9536492cca0c11588113a2 Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-43%2Fdscho%2Frebase-i-break-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-43/dscho/rebase-i-break-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/43 Range-diff vs v1: -: ---------- > 1: 2eefdb4874 rebase -i: clarify what happens on a failed `exec` 1: b358178548 ! 2: c74e02c4b6 rebase -i: introduce the 'break' command @@ -11,11 +11,26 @@ before cherry-picking a commit, or immediately after an 'exec' or a 'merge'. - This commit introduces that functionality, as the spanking new 'break' command. + This commit introduces that functionality, as the spanking new 'break' + command. Suggested-by: Stefan Beller <sbeller@google.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> +diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt +--- a/Documentation/git-rebase.txt ++++ b/Documentation/git-rebase.txt +@@ + the files and/or the commit message, amend the commit, and continue + rebasing. + ++To interrupt the rebase (just like an "edit" command would do, but without ++cherry-picking any commit first), use the "break" command. ++ + If you just want to edit the commit message for a commit, replace the + command "pick" with the command "reword". + + diff --git a/rebase-interactive.c b/rebase-interactive.c --- a/rebase-interactive.c +++ b/rebase-interactive.c -- gitgitgadget ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` 2018-10-10 8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget @ 2018-10-10 8:53 ` Johannes Schindelin via GitGitGadget 2018-10-10 9:46 ` Eric Sunshine 2018-10-10 8:53 ` [PATCH v2 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget 2 siblings, 1 reply; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-10 8:53 UTC (permalink / raw) To: git; +Cc: Stefan Beller, Junio C Hamano, Johannes Schindelin From: Johannes Schindelin <johannes.schindelin@gmx.de> We had not documented previously what happens when an `exec` command in an interactive rebase fails. Now we do. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- Documentation/git-rebase.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 091eb53faa..db2faca73c 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). --exec <cmd>:: Append "exec <cmd>" after each line creating a commit in the final history. <cmd> will be interpreted as one or more shell - commands. + commands. Anz command that fails will interrupt the rebase, + withe exit code 1. + You may execute several commands by either using one instance of `--exec` with several commands: -- gitgitgadget ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` 2018-10-10 8:53 ` [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget @ 2018-10-10 9:46 ` Eric Sunshine 2018-10-11 8:15 ` Junio C Hamano 0 siblings, 1 reply; 27+ messages in thread From: Eric Sunshine @ 2018-10-10 9:46 UTC (permalink / raw) To: gitgitgadget; +Cc: Git List, Stefan Beller, Junio C Hamano, Johannes Schindelin On Wed, Oct 10, 2018 at 4:54 AM Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> wrote: > We had not documented previously what happens when an `exec` command in > an interactive rebase fails. Now we do. > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). > --exec <cmd>:: > Append "exec <cmd>" after each line creating a commit in the > final history. <cmd> will be interpreted as one or more shell > - commands. > + commands. Anz command that fails will interrupt the rebase, > + withe exit code 1. s/Anz/Any/ s/withe/with/ ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` 2018-10-10 9:46 ` Eric Sunshine @ 2018-10-11 8:15 ` Junio C Hamano 2018-10-12 8:36 ` Johannes Schindelin 0 siblings, 1 reply; 27+ messages in thread From: Junio C Hamano @ 2018-10-11 8:15 UTC (permalink / raw) To: Eric Sunshine; +Cc: gitgitgadget, Git List, Stefan Beller, Johannes Schindelin Eric Sunshine <sunshine@sunshineco.com> writes: > On Wed, Oct 10, 2018 at 4:54 AM Johannes Schindelin via GitGitGadget > <gitgitgadget@gmail.com> wrote: >> We had not documented previously what happens when an `exec` command in >> an interactive rebase fails. Now we do. >> >> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> >> --- >> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt >> @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). >> --exec <cmd>:: >> Append "exec <cmd>" after each line creating a commit in the >> final history. <cmd> will be interpreted as one or more shell >> - commands. >> + commands. Anz command that fails will interrupt the rebase, >> + withe exit code 1. > > s/Anz/Any/ > s/withe/with/ Heh, I know I am not good at spelling, either, but hopefully I am a bit more careful than leaving as many typoes as I have added lines in my patch X-<. After all, it's not a race to send in patches as quickly as possible. Queued. Thanks, both. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` 2018-10-11 8:15 ` Junio C Hamano @ 2018-10-12 8:36 ` Johannes Schindelin 0 siblings, 0 replies; 27+ messages in thread From: Johannes Schindelin @ 2018-10-12 8:36 UTC (permalink / raw) To: Junio C Hamano; +Cc: Eric Sunshine, gitgitgadget, Git List, Stefan Beller Hi Junio & Eric, On Thu, 11 Oct 2018, Junio C Hamano wrote: > Eric Sunshine <sunshine@sunshineco.com> writes: > > > On Wed, Oct 10, 2018 at 4:54 AM Johannes Schindelin via GitGitGadget > > <gitgitgadget@gmail.com> wrote: > >> We had not documented previously what happens when an `exec` command in > >> an interactive rebase fails. Now we do. > >> > >> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > >> --- > >> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > >> @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). > >> --exec <cmd>:: > >> Append "exec <cmd>" after each line creating a commit in the > >> final history. <cmd> will be interpreted as one or more shell > >> - commands. > >> + commands. Anz command that fails will interrupt the rebase, > >> + withe exit code 1. > > > > s/Anz/Any/ > > s/withe/with/ These tyopes will be fxied in the nxet itaretion. Ciao, Dhsco > > Heh, I know I am not good at spelling, either, but hopefully I am a > bit more careful than leaving as many typoes as I have added lines > in my patch X-<. After all, it's not a race to send in patches as > quickly as possible. > > Queued. Thanks, both. > ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 2/2] rebase -i: introduce the 'break' command 2018-10-10 8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget 2018-10-10 8:53 ` [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget @ 2018-10-10 8:53 ` Johannes Schindelin via GitGitGadget 2018-10-11 9:08 ` Phillip Wood 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget 2 siblings, 1 reply; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-10 8:53 UTC (permalink / raw) To: git; +Cc: Stefan Beller, Junio C Hamano, Johannes Schindelin From: Johannes Schindelin <johannes.schindelin@gmx.de> The 'edit' command can be used to cherry-pick a commit and then immediately drop out of the interactive rebase, with exit code 0, to let the user amend the commit, or test it, or look around. Sometimes this functionality would come in handy *without* cherry-picking a commit, e.g. to interrupt the interactive rebase even before cherry-picking a commit, or immediately after an 'exec' or a 'merge'. This commit introduces that functionality, as the spanking new 'break' command. Suggested-by: Stefan Beller <sbeller@google.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- Documentation/git-rebase.txt | 3 +++ rebase-interactive.c | 1 + sequencer.c | 7 ++++++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 9 +++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index db2faca73c..5bed1da36b 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -561,6 +561,9 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. +To interrupt the rebase (just like an "edit" command would do, but without +cherry-picking any commit first), use the "break" command. + If you just want to edit the commit message for a commit, replace the command "pick" with the command "reword". diff --git a/rebase-interactive.c b/rebase-interactive.c index 0f4119cbae..78f3263fc1 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -14,6 +14,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty, "s, squash <commit> = use commit, but meld into previous commit\n" "f, fixup <commit> = like \"squash\", but discard this commit's log message\n" "x, exec <command> = run command (the rest of the line) using shell\n" +"b, break = stop here (continue rebase later with 'git rebase --continue')\n" "d, drop <commit> = remove commit\n" "l, label <label> = label current HEAD with a name\n" "t, reset <label> = reset HEAD to a label\n" diff --git a/sequencer.c b/sequencer.c index 8dd6db5a01..b209f8af46 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1416,6 +1416,7 @@ enum todo_command { TODO_SQUASH, /* commands that do something else than handling a single commit */ TODO_EXEC, + TODO_BREAK, TODO_LABEL, TODO_RESET, TODO_MERGE, @@ -1437,6 +1438,7 @@ static struct { { 'f', "fixup" }, { 's', "squash" }, { 'x', "exec" }, + { 'b', "break" }, { 'l', "label" }, { 't', "reset" }, { 'm', "merge" }, @@ -1964,7 +1966,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) padding = strspn(bol, " \t"); bol += padding; - if (item->command == TODO_NOOP) { + if (item->command == TODO_NOOP || item->command == TODO_BREAK) { if (bol != eol) return error(_("%s does not accept arguments: '%s'"), command_to_string(item->command), bol); @@ -3293,6 +3295,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) unlink(rebase_path_stopped_sha()); unlink(rebase_path_amend()); delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); + + if (item->command == TODO_BREAK) + break; } if (item->command <= TODO_SQUASH) { if (is_rebase_i(opts)) diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 25a77ee5cb..584604ee63 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -49,7 +49,7 @@ set_fake_editor () { case $line in squash|fixup|edit|reword|drop) action="$line";; - exec*) + exec*|break) echo "$line" | sed 's/_/ /g' >> "$1";; "#") echo '# comment' >> "$1";; diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index c145dbac38..185a491089 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -239,5 +239,14 @@ test_rerere_autoupdate -m GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR test_rerere_autoupdate -i test_rerere_autoupdate --preserve-merges +unset GIT_SEQUENCE_EDITOR + +test_expect_success 'the todo command "break" works' ' + rm -f execed && + FAKE_LINES="break exec_>execed" git rebase -i HEAD && + test_path_is_missing execed && + git rebase --continue && + test_path_is_file execed +' test_done -- gitgitgadget ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/2] rebase -i: introduce the 'break' command 2018-10-10 8:53 ` [PATCH v2 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget @ 2018-10-11 9:08 ` Phillip Wood 2018-10-12 8:35 ` Johannes Schindelin 0 siblings, 1 reply; 27+ messages in thread From: Phillip Wood @ 2018-10-11 9:08 UTC (permalink / raw) To: Johannes Schindelin via GitGitGadget, git Cc: Stefan Beller, Junio C Hamano, Johannes Schindelin Hi Johannes I think this would be a useful addition to rebase, there's one small comment below. On 10/10/2018 09:53, Johannes Schindelin via GitGitGadget wrote: > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > The 'edit' command can be used to cherry-pick a commit and then > immediately drop out of the interactive rebase, with exit code 0, to let > the user amend the commit, or test it, or look around. > > Sometimes this functionality would come in handy *without* > cherry-picking a commit, e.g. to interrupt the interactive rebase even > before cherry-picking a commit, or immediately after an 'exec' or a > 'merge'. > > This commit introduces that functionality, as the spanking new 'break' > command. > > Suggested-by: Stefan Beller <sbeller@google.com> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > Documentation/git-rebase.txt | 3 +++ > rebase-interactive.c | 1 + > sequencer.c | 7 ++++++- > t/lib-rebase.sh | 2 +- > t/t3418-rebase-continue.sh | 9 +++++++++ > 5 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > index db2faca73c..5bed1da36b 100644 > --- a/Documentation/git-rebase.txt > +++ b/Documentation/git-rebase.txt > @@ -561,6 +561,9 @@ By replacing the command "pick" with the command "edit", you can tell > the files and/or the commit message, amend the commit, and continue > rebasing. > > +To interrupt the rebase (just like an "edit" command would do, but without > +cherry-picking any commit first), use the "break" command. > + > If you just want to edit the commit message for a commit, replace the > command "pick" with the command "reword". > > diff --git a/rebase-interactive.c b/rebase-interactive.c > index 0f4119cbae..78f3263fc1 100644 > --- a/rebase-interactive.c > +++ b/rebase-interactive.c > @@ -14,6 +14,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty, > "s, squash <commit> = use commit, but meld into previous commit\n" > "f, fixup <commit> = like \"squash\", but discard this commit's log message\n" > "x, exec <command> = run command (the rest of the line) using shell\n" > +"b, break = stop here (continue rebase later with 'git rebase --continue')\n" > "d, drop <commit> = remove commit\n" > "l, label <label> = label current HEAD with a name\n" > "t, reset <label> = reset HEAD to a label\n" > diff --git a/sequencer.c b/sequencer.c > index 8dd6db5a01..b209f8af46 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -1416,6 +1416,7 @@ enum todo_command { > TODO_SQUASH, > /* commands that do something else than handling a single commit */ > TODO_EXEC, > + TODO_BREAK, > TODO_LABEL, > TODO_RESET, > TODO_MERGE, > @@ -1437,6 +1438,7 @@ static struct { > { 'f', "fixup" }, > { 's', "squash" }, > { 'x', "exec" }, > + { 'b', "break" }, > { 'l', "label" }, > { 't', "reset" }, > { 'm', "merge" }, > @@ -1964,7 +1966,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) > padding = strspn(bol, " \t"); > bol += padding; > > - if (item->command == TODO_NOOP) { > + if (item->command == TODO_NOOP || item->command == TODO_BREAK) { > if (bol != eol) > return error(_("%s does not accept arguments: '%s'"), > command_to_string(item->command), bol); > @@ -3293,6 +3295,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) > unlink(rebase_path_stopped_sha()); > unlink(rebase_path_amend()); > delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); > + > + if (item->command == TODO_BREAK) > + break; Normally when rebase stops it prints a message to say where it has got to and how to continue, it might be useful to do the same here Best Wishes Phillip > } > if (item->command <= TODO_SQUASH) { > if (is_rebase_i(opts)) > diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh > index 25a77ee5cb..584604ee63 100644 > --- a/t/lib-rebase.sh > +++ b/t/lib-rebase.sh > @@ -49,7 +49,7 @@ set_fake_editor () { > case $line in > squash|fixup|edit|reword|drop) > action="$line";; > - exec*) > + exec*|break) > echo "$line" | sed 's/_/ /g' >> "$1";; > "#") > echo '# comment' >> "$1";; > diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh > index c145dbac38..185a491089 100755 > --- a/t/t3418-rebase-continue.sh > +++ b/t/t3418-rebase-continue.sh > @@ -239,5 +239,14 @@ test_rerere_autoupdate -m > GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR > test_rerere_autoupdate -i > test_rerere_autoupdate --preserve-merges > +unset GIT_SEQUENCE_EDITOR > + > +test_expect_success 'the todo command "break" works' ' > + rm -f execed && > + FAKE_LINES="break exec_>execed" git rebase -i HEAD && > + test_path_is_missing execed && > + git rebase --continue && > + test_path_is_file execed > +' > > test_done > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/2] rebase -i: introduce the 'break' command 2018-10-11 9:08 ` Phillip Wood @ 2018-10-12 8:35 ` Johannes Schindelin 2018-10-12 11:09 ` Phillip Wood 0 siblings, 1 reply; 27+ messages in thread From: Johannes Schindelin @ 2018-10-12 8:35 UTC (permalink / raw) To: phillip.wood Cc: Johannes Schindelin via GitGitGadget, git, Stefan Beller, Junio C Hamano Hi Phillip, On Thu, 11 Oct 2018, Phillip Wood wrote: > I think this would be a useful addition to rebase, there's one small > comment below. > > On 10/10/2018 09:53, Johannes Schindelin via GitGitGadget wrote: > > From: Johannes Schindelin <johannes.schindelin@gmx.de> > > > > The 'edit' command can be used to cherry-pick a commit and then > > immediately drop out of the interactive rebase, with exit code 0, to let > > the user amend the commit, or test it, or look around. > > > > Sometimes this functionality would come in handy *without* > > cherry-picking a commit, e.g. to interrupt the interactive rebase even > > before cherry-picking a commit, or immediately after an 'exec' or a > > 'merge'. > > > > This commit introduces that functionality, as the spanking new 'break' > > command. > > > > Suggested-by: Stefan Beller <sbeller@google.com> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > > --- > > Documentation/git-rebase.txt | 3 +++ > > rebase-interactive.c | 1 + > > sequencer.c | 7 ++++++- > > t/lib-rebase.sh | 2 +- > > t/t3418-rebase-continue.sh | 9 +++++++++ > > 5 files changed, 20 insertions(+), 2 deletions(-) > > > > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > > index db2faca73c..5bed1da36b 100644 > > --- a/Documentation/git-rebase.txt > > +++ b/Documentation/git-rebase.txt > > @@ -561,6 +561,9 @@ By replacing the command "pick" with the command "edit", you can tell > > the files and/or the commit message, amend the commit, and continue > > rebasing. > > > > +To interrupt the rebase (just like an "edit" command would do, but without > > +cherry-picking any commit first), use the "break" command. > > + > > If you just want to edit the commit message for a commit, replace the > > command "pick" with the command "reword". > > > > diff --git a/rebase-interactive.c b/rebase-interactive.c > > index 0f4119cbae..78f3263fc1 100644 > > --- a/rebase-interactive.c > > +++ b/rebase-interactive.c > > @@ -14,6 +14,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty, > > "s, squash <commit> = use commit, but meld into previous commit\n" > > "f, fixup <commit> = like \"squash\", but discard this commit's log message\n" > > "x, exec <command> = run command (the rest of the line) using shell\n" > > +"b, break = stop here (continue rebase later with 'git rebase --continue')\n" > > "d, drop <commit> = remove commit\n" > > "l, label <label> = label current HEAD with a name\n" > > "t, reset <label> = reset HEAD to a label\n" > > diff --git a/sequencer.c b/sequencer.c > > index 8dd6db5a01..b209f8af46 100644 > > --- a/sequencer.c > > +++ b/sequencer.c > > @@ -1416,6 +1416,7 @@ enum todo_command { > > TODO_SQUASH, > > /* commands that do something else than handling a single commit */ > > TODO_EXEC, > > + TODO_BREAK, > > TODO_LABEL, > > TODO_RESET, > > TODO_MERGE, > > @@ -1437,6 +1438,7 @@ static struct { > > { 'f', "fixup" }, > > { 's', "squash" }, > > { 'x', "exec" }, > > + { 'b', "break" }, > > { 'l', "label" }, > > { 't', "reset" }, > > { 'm', "merge" }, > > @@ -1964,7 +1966,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) > > padding = strspn(bol, " \t"); > > bol += padding; > > > > - if (item->command == TODO_NOOP) { > > + if (item->command == TODO_NOOP || item->command == TODO_BREAK) { > > if (bol != eol) > > return error(_("%s does not accept arguments: '%s'"), > > command_to_string(item->command), bol); > > @@ -3293,6 +3295,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) > > unlink(rebase_path_stopped_sha()); > > unlink(rebase_path_amend()); > > delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); > > + > > + if (item->command == TODO_BREAK) > > + break; > > Normally when rebase stops it prints a message to say where it has got > to and how to continue, it might be useful to do the same here That's a very valid point. I'll think of something. Ciao, Dscho > > Best Wishes > > Phillip > > > } > > if (item->command <= TODO_SQUASH) { > > if (is_rebase_i(opts)) > > diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh > > index 25a77ee5cb..584604ee63 100644 > > --- a/t/lib-rebase.sh > > +++ b/t/lib-rebase.sh > > @@ -49,7 +49,7 @@ set_fake_editor () { > > case $line in > > squash|fixup|edit|reword|drop) > > action="$line";; > > - exec*) > > + exec*|break) > > echo "$line" | sed 's/_/ /g' >> "$1";; > > "#") > > echo '# comment' >> "$1";; > > diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh > > index c145dbac38..185a491089 100755 > > --- a/t/t3418-rebase-continue.sh > > +++ b/t/t3418-rebase-continue.sh > > @@ -239,5 +239,14 @@ test_rerere_autoupdate -m > > GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR > > test_rerere_autoupdate -i > > test_rerere_autoupdate --preserve-merges > > +unset GIT_SEQUENCE_EDITOR > > + > > +test_expect_success 'the todo command "break" works' ' > > + rm -f execed && > > + FAKE_LINES="break exec_>execed" git rebase -i HEAD && > > + test_path_is_missing execed && > > + git rebase --continue && > > + test_path_is_file execed > > +' > > > > test_done > > > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/2] rebase -i: introduce the 'break' command 2018-10-12 8:35 ` Johannes Schindelin @ 2018-10-12 11:09 ` Phillip Wood 2018-10-12 11:24 ` Johannes Schindelin 0 siblings, 1 reply; 27+ messages in thread From: Phillip Wood @ 2018-10-12 11:09 UTC (permalink / raw) To: Johannes Schindelin, phillip.wood Cc: Johannes Schindelin via GitGitGadget, git, Stefan Beller, Junio C Hamano Hi Johannes On 12/10/2018 09:35, Johannes Schindelin wrote: > Hi Phillip, > > On Thu, 11 Oct 2018, Phillip Wood wrote: > >> I think this would be a useful addition to rebase, there's one small >> comment below. >> >> On 10/10/2018 09:53, Johannes Schindelin via GitGitGadget wrote: >>> From: Johannes Schindelin <johannes.schindelin@gmx.de> >>> >>> The 'edit' command can be used to cherry-pick a commit and then >>> immediately drop out of the interactive rebase, with exit code 0, to let >>> the user amend the commit, or test it, or look around. >>> >>> Sometimes this functionality would come in handy *without* >>> cherry-picking a commit, e.g. to interrupt the interactive rebase even >>> before cherry-picking a commit, or immediately after an 'exec' or a >>> 'merge'. >>> >>> This commit introduces that functionality, as the spanking new 'break' >>> command. >>> >>> Suggested-by: Stefan Beller <sbeller@google.com> >>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> >>> --- >>> diff --git a/sequencer.c b/sequencer.c >>> index 8dd6db5a01..b209f8af46 100644 >>> --- a/sequencer.c >>> +++ b/sequencer.c >>> @@ -3293,6 +3295,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) >>> unlink(rebase_path_stopped_sha()); >>> unlink(rebase_path_amend()); >>> delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); >>> + >>> + if (item->command == TODO_BREAK) >>> + break; >> >> Normally when rebase stops it prints a message to say where it has got >> to and how to continue, it might be useful to do the same here > > That's a very valid point. I'll think of something. I'm not sure what gets left on the screen from the previous picks but something to say what the last pick/exec was and maybe what the current HEAD is would be useful I think. One thing has just occurred to me - what does git status say (and does it still work - I'm not sure how much parsing it does on the todo and done files) if it is run while rebase is stopped on a break command? Best Wishes Phillip ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/2] rebase -i: introduce the 'break' command 2018-10-12 11:09 ` Phillip Wood @ 2018-10-12 11:24 ` Johannes Schindelin 0 siblings, 0 replies; 27+ messages in thread From: Johannes Schindelin @ 2018-10-12 11:24 UTC (permalink / raw) To: phillip.wood Cc: Johannes Schindelin via GitGitGadget, git, Stefan Beller, Junio C Hamano Hi Phillip, On Fri, 12 Oct 2018, Phillip Wood wrote: > Hi Johannes > On 12/10/2018 09:35, Johannes Schindelin wrote: > > Hi Phillip, > > > > On Thu, 11 Oct 2018, Phillip Wood wrote: > > > >> I think this would be a useful addition to rebase, there's one small > >> comment below. > >> > >> On 10/10/2018 09:53, Johannes Schindelin via GitGitGadget wrote: > >>> From: Johannes Schindelin <johannes.schindelin@gmx.de> > >>> > >>> The 'edit' command can be used to cherry-pick a commit and then > >>> immediately drop out of the interactive rebase, with exit code 0, to let > >>> the user amend the commit, or test it, or look around. > >>> > >>> Sometimes this functionality would come in handy *without* > >>> cherry-picking a commit, e.g. to interrupt the interactive rebase even > >>> before cherry-picking a commit, or immediately after an 'exec' or a > >>> 'merge'. > >>> > >>> This commit introduces that functionality, as the spanking new 'break' > >>> command. > >>> > >>> Suggested-by: Stefan Beller <sbeller@google.com> > >>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > >>> --- > > >>> diff --git a/sequencer.c b/sequencer.c > >>> index 8dd6db5a01..b209f8af46 100644 > >>> --- a/sequencer.c > >>> +++ b/sequencer.c > > >>> @@ -3293,6 +3295,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) > >>> unlink(rebase_path_stopped_sha()); > >>> unlink(rebase_path_amend()); > >>> delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); > >>> + > >>> + if (item->command == TODO_BREAK) > >>> + break; > >> > >> Normally when rebase stops it prints a message to say where it has got > >> to and how to continue, it might be useful to do the same here > > > > That's a very valid point. I'll think of something. > > I'm not sure what gets left on the screen from the previous picks but > something to say what the last pick/exec was and maybe what the current > HEAD is would be useful I think. I first wanted to do that, imitating the "Stopped at <hex>... <oneline>" of an `edit` command, but it *is* now possible that we are on an unborn branch... which will look a bit funny, I guess, as we construct a very special place-holder commit to be HEAD in that case. > One thing has just occurred to me - what does git status say (and does > it still work - I'm not sure how much parsing it does on the todo and > done files) if it is run while rebase is stopped on a break command? I don't think it says anything special, really. It just reports that we're in the middle of a rebase, listing up to two already-processed and up to two to-be-processed todo commands. Ciao, Dscho ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v3 0/2] rebase -i: introduce the 'break' command 2018-10-10 8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget 2018-10-10 8:53 ` [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget 2018-10-10 8:53 ` [PATCH v2 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget @ 2018-10-12 13:14 ` Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget ` (3 more replies) 2 siblings, 4 replies; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-12 13:14 UTC (permalink / raw) To: git; +Cc: Phillip Wood, Junio C Hamano Stefan asked a while back [https://public-inbox.org/git/20180118183618.39853-3-sbeller@google.com/] for a todo command in interactive rebases that would essentially perform the "stop" part of the edit command, but without the "pick" part: interrupt the interactive rebase, with exit code 0, letting the user do things and stuff and look around, with the idea of continuing the rebase later (using git rebase --continue). This patch introduces that, based on ag/rebase-i-in-c. Changes since v2: * Fixed two typos. * When interrupting the rebase, break now outputs a message. Changes since v1: * Wrapped the commit message correctly. * Added a preparatory patch to mention what happens in case an exec fails. * Mentioned the break command in the git-rebase(1) documentation. Cc: Stefan Beller sbeller@google.com [sbeller@google.com]Cc: Eric Sunshine sunshine@sunshineco.com [sunshine@sunshineco.com] Johannes Schindelin (2): rebase -i: clarify what happens on a failed `exec` rebase -i: introduce the 'break' command Documentation/git-rebase.txt | 6 +++++- rebase-interactive.c | 1 + sequencer.c | 24 +++++++++++++++++++++++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 9 +++++++++ 5 files changed, 39 insertions(+), 3 deletions(-) base-commit: 34b47315d9721a576b9536492cca0c11588113a2 Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-43%2Fdscho%2Frebase-i-break-v3 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-43/dscho/rebase-i-break-v3 Pull-Request: https://github.com/gitgitgadget/git/pull/43 Range-diff vs v2: 1: 2eefdb4874 ! 1: 92512a82d2 rebase -i: clarify what happens on a failed `exec` @@ -15,8 +15,8 @@ Append "exec <cmd>" after each line creating a commit in the final history. <cmd> will be interpreted as one or more shell - commands. -+ commands. Anz command that fails will interrupt the rebase, -+ withe exit code 1. ++ commands. Any command that fails will interrupt the rebase, ++ with exit code 1. + You may execute several commands by either using one instance of `--exec` with several commands: 2: c74e02c4b6 ! 2: d44b425709 rebase -i: introduce the 'break' command @@ -71,13 +71,37 @@ if (bol != eol) return error(_("%s does not accept arguments: '%s'"), command_to_string(item->command), bol); +@@ + return update_ref(NULL, "ORIG_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR); + } + ++static int stopped_at_head(void) ++{ ++ struct object_id head; ++ struct commit *commit; ++ struct commit_message message; ++ ++ if (get_oid("HEAD", &head) || !(commit = lookup_commit(&head)) || ++ parse_commit(commit) || get_message(commit, &message)) ++ fprintf(stderr, _("Stopped at HEAD\n")); ++ else { ++ fprintf(stderr, _("Stopped at %s\n"), message.label); ++ free_message(commit, &message); ++ } ++ return 0; ++ ++} ++ + static const char rescheduled_advice[] = + N_("Could not execute the todo command\n" + "\n" @@ unlink(rebase_path_stopped_sha()); unlink(rebase_path_amend()); delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); + + if (item->command == TODO_BREAK) -+ break; ++ return stopped_at_head(); } if (item->command <= TODO_SQUASH) { if (is_rebase_i(opts)) -- gitgitgadget ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v3 1/2] rebase -i: clarify what happens on a failed `exec` 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget @ 2018-10-12 13:14 ` Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget ` (2 subsequent siblings) 3 siblings, 0 replies; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-12 13:14 UTC (permalink / raw) To: git; +Cc: Phillip Wood, Junio C Hamano, Johannes Schindelin From: Johannes Schindelin <johannes.schindelin@gmx.de> We had not documented previously what happens when an `exec` command in an interactive rebase fails. Now we do. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- Documentation/git-rebase.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 091eb53faa..d9771bd25b 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -420,7 +420,8 @@ idea unless you know what you are doing (see BUGS below). --exec <cmd>:: Append "exec <cmd>" after each line creating a commit in the final history. <cmd> will be interpreted as one or more shell - commands. + commands. Any command that fails will interrupt the rebase, + with exit code 1. + You may execute several commands by either using one instance of `--exec` with several commands: -- gitgitgadget ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v3 2/2] rebase -i: introduce the 'break' command 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget @ 2018-10-12 13:14 ` Johannes Schindelin via GitGitGadget 2018-10-12 14:09 ` Junio C Hamano 2018-10-12 14:01 ` [PATCH v3 0/2] " Junio C Hamano 2018-10-25 20:47 ` [PATCH 3/2] rebase -i: recognize short commands without arguments Johannes Sixt 3 siblings, 1 reply; 27+ messages in thread From: Johannes Schindelin via GitGitGadget @ 2018-10-12 13:14 UTC (permalink / raw) To: git; +Cc: Phillip Wood, Junio C Hamano, Johannes Schindelin From: Johannes Schindelin <johannes.schindelin@gmx.de> The 'edit' command can be used to cherry-pick a commit and then immediately drop out of the interactive rebase, with exit code 0, to let the user amend the commit, or test it, or look around. Sometimes this functionality would come in handy *without* cherry-picking a commit, e.g. to interrupt the interactive rebase even before cherry-picking a commit, or immediately after an 'exec' or a 'merge'. This commit introduces that functionality, as the spanking new 'break' command. Suggested-by: Stefan Beller <sbeller@google.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- Documentation/git-rebase.txt | 3 +++ rebase-interactive.c | 1 + sequencer.c | 24 +++++++++++++++++++++++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 9 +++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index d9771bd25b..6b71694b0d 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -561,6 +561,9 @@ By replacing the command "pick" with the command "edit", you can tell the files and/or the commit message, amend the commit, and continue rebasing. +To interrupt the rebase (just like an "edit" command would do, but without +cherry-picking any commit first), use the "break" command. + If you just want to edit the commit message for a commit, replace the command "pick" with the command "reword". diff --git a/rebase-interactive.c b/rebase-interactive.c index 0f4119cbae..78f3263fc1 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -14,6 +14,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty, "s, squash <commit> = use commit, but meld into previous commit\n" "f, fixup <commit> = like \"squash\", but discard this commit's log message\n" "x, exec <command> = run command (the rest of the line) using shell\n" +"b, break = stop here (continue rebase later with 'git rebase --continue')\n" "d, drop <commit> = remove commit\n" "l, label <label> = label current HEAD with a name\n" "t, reset <label> = reset HEAD to a label\n" diff --git a/sequencer.c b/sequencer.c index 8dd6db5a01..ee3961ec63 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1416,6 +1416,7 @@ enum todo_command { TODO_SQUASH, /* commands that do something else than handling a single commit */ TODO_EXEC, + TODO_BREAK, TODO_LABEL, TODO_RESET, TODO_MERGE, @@ -1437,6 +1438,7 @@ static struct { { 'f', "fixup" }, { 's', "squash" }, { 'x', "exec" }, + { 'b', "break" }, { 'l', "label" }, { 't', "reset" }, { 'm', "merge" }, @@ -1964,7 +1966,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) padding = strspn(bol, " \t"); bol += padding; - if (item->command == TODO_NOOP) { + if (item->command == TODO_NOOP || item->command == TODO_BREAK) { if (bol != eol) return error(_("%s does not accept arguments: '%s'"), command_to_string(item->command), bol); @@ -3247,6 +3249,23 @@ static int checkout_onto(struct replay_opts *opts, return update_ref(NULL, "ORIG_HEAD", &oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR); } +static int stopped_at_head(void) +{ + struct object_id head; + struct commit *commit; + struct commit_message message; + + if (get_oid("HEAD", &head) || !(commit = lookup_commit(&head)) || + parse_commit(commit) || get_message(commit, &message)) + fprintf(stderr, _("Stopped at HEAD\n")); + else { + fprintf(stderr, _("Stopped at %s\n"), message.label); + free_message(commit, &message); + } + return 0; + +} + static const char rescheduled_advice[] = N_("Could not execute the todo command\n" "\n" @@ -3293,6 +3312,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) unlink(rebase_path_stopped_sha()); unlink(rebase_path_amend()); delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); + + if (item->command == TODO_BREAK) + return stopped_at_head(); } if (item->command <= TODO_SQUASH) { if (is_rebase_i(opts)) diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 25a77ee5cb..584604ee63 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -49,7 +49,7 @@ set_fake_editor () { case $line in squash|fixup|edit|reword|drop) action="$line";; - exec*) + exec*|break) echo "$line" | sed 's/_/ /g' >> "$1";; "#") echo '# comment' >> "$1";; diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index c145dbac38..185a491089 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -239,5 +239,14 @@ test_rerere_autoupdate -m GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR test_rerere_autoupdate -i test_rerere_autoupdate --preserve-merges +unset GIT_SEQUENCE_EDITOR + +test_expect_success 'the todo command "break" works' ' + rm -f execed && + FAKE_LINES="break exec_>execed" git rebase -i HEAD && + test_path_is_missing execed && + git rebase --continue && + test_path_is_file execed +' test_done -- gitgitgadget ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v3 2/2] rebase -i: introduce the 'break' command 2018-10-12 13:14 ` [PATCH v3 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget @ 2018-10-12 14:09 ` Junio C Hamano 2018-10-12 15:31 ` Johannes Schindelin 0 siblings, 1 reply; 27+ messages in thread From: Junio C Hamano @ 2018-10-12 14:09 UTC (permalink / raw) To: Johannes Schindelin via GitGitGadget Cc: git, Phillip Wood, Johannes Schindelin "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > @@ -3293,6 +3312,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) > unlink(rebase_path_stopped_sha()); > unlink(rebase_path_amend()); > delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); > + > + if (item->command == TODO_BREAK) > + return stopped_at_head(); > } The earlier one had "break;" here, which broke out of the while() loop, let the control reach "if (is_reabse_i(opts)) {" block after the loop, and the block would have noticed that current < nr and returned 0. So from the point of view of the overall control flow of the caller of this function, there is no change relative to v2. The only difference in v3 is that stopped_at_head() gives a useful message. Good. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v3 2/2] rebase -i: introduce the 'break' command 2018-10-12 14:09 ` Junio C Hamano @ 2018-10-12 15:31 ` Johannes Schindelin 0 siblings, 0 replies; 27+ messages in thread From: Johannes Schindelin @ 2018-10-12 15:31 UTC (permalink / raw) To: Junio C Hamano; +Cc: Johannes Schindelin via GitGitGadget, git, Phillip Wood Hi Junio, On Fri, 12 Oct 2018, Junio C Hamano wrote: > "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> > writes: > > > @@ -3293,6 +3312,9 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) > > unlink(rebase_path_stopped_sha()); > > unlink(rebase_path_amend()); > > delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); > > + > > + if (item->command == TODO_BREAK) > > + return stopped_at_head(); > > } > > The earlier one had "break;" here, which broke out of the while() > loop, let the control reach "if (is_reabse_i(opts)) {" block after > the loop, and the block would have noticed that current < nr and > returned 0. So from the point of view of the overall control flow > of the caller of this function, there is no change relative to v2. > The only difference in v3 is that stopped_at_head() gives a useful > message. Well, I should have called out this `break;` -> `return 0;` change, too, as I think it makes the code flow *a lot* more obvious. As you say, I relied earlier on the next loop to return early, but that is not what the `edit` command does: it returns out of the first loop, too. > > Good. Thanks, Dscho > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v3 0/2] rebase -i: introduce the 'break' command 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget @ 2018-10-12 14:01 ` Junio C Hamano 2018-10-12 15:32 ` Johannes Schindelin 2018-10-25 20:47 ` [PATCH 3/2] rebase -i: recognize short commands without arguments Johannes Sixt 3 siblings, 1 reply; 27+ messages in thread From: Junio C Hamano @ 2018-10-12 14:01 UTC (permalink / raw) To: Johannes Schindelin via GitGitGadget; +Cc: git, Phillip Wood "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes: > This patch introduces that, based on ag/rebase-i-in-c. > > Changes since v2: > > * Fixed two typos. > * When interrupting the rebase, break now outputs a message. I was about to merge the whole collection of topics to 'next', but this came to stop me just in time. The typofixes are appreciated of course, and look trivially correct. I find that the if() condition that does too many side-effect-full operations in stopped-at-head shows bad taste. It is still short enough to understand what each step is trying to do, but would encourage others who later may touch the code to make it even more complex. But it is a short and isolated static helper function, so I won't complain too loudly. Will replace and requeue. Thanks. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v3 0/2] rebase -i: introduce the 'break' command 2018-10-12 14:01 ` [PATCH v3 0/2] " Junio C Hamano @ 2018-10-12 15:32 ` Johannes Schindelin 0 siblings, 0 replies; 27+ messages in thread From: Johannes Schindelin @ 2018-10-12 15:32 UTC (permalink / raw) To: Junio C Hamano; +Cc: Johannes Schindelin via GitGitGadget, git, Phillip Wood Hi Junio, On Fri, 12 Oct 2018, Junio C Hamano wrote: > "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> > writes: > > > This patch introduces that, based on ag/rebase-i-in-c. > > > > Changes since v2: > > > > * Fixed two typos. > > * When interrupting the rebase, break now outputs a message. > > I was about to merge the whole collection of topics to 'next', but > this came to stop me just in time. > > The typofixes are appreciated of course, and look trivially correct. > > I find that the if() condition that does too many side-effect-full > operations in stopped-at-head shows bad taste. It is still short > enough to understand what each step is trying to do, but would > encourage others who later may touch the code to make it even more > complex. > > But it is a short and isolated static helper function, so I won't > complain too loudly. > > Will replace and requeue. Thanks, Dscho > > Thanks. > ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 3/2] rebase -i: recognize short commands without arguments 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget ` (2 preceding siblings ...) 2018-10-12 14:01 ` [PATCH v3 0/2] " Junio C Hamano @ 2018-10-25 20:47 ` Johannes Sixt 2018-10-26 1:26 ` Junio C Hamano 2018-10-26 8:04 ` Johannes Schindelin 3 siblings, 2 replies; 27+ messages in thread From: Johannes Sixt @ 2018-10-25 20:47 UTC (permalink / raw) To: Johannes Schindelin via GitGitGadget; +Cc: git, Phillip Wood, Junio C Hamano The sequencer instruction 'b', short for 'break', is rejected: error: invalid line 2: b The reason is that the parser expects all short commands to have an argument. Permit short commands without arguments. Signed-off-by: Johannes Sixt <j6t@kdbg.org> --- I'll send a another patch in a moment that tests all short sequencer commands, but it is independent from this topic. sequencer.c | 3 ++- t/lib-rebase.sh | 2 +- t/t3418-rebase-continue.sh | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sequencer.c b/sequencer.c index ee3961ec63..3107f59ea7 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1954,7 +1954,8 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) if (skip_prefix(bol, todo_command_info[i].str, &bol)) { item->command = i; break; - } else if (bol[1] == ' ' && *bol == todo_command_info[i].c) { + } else if ((bol + 1 == eol || bol[1] == ' ') && + *bol == todo_command_info[i].c) { bol++; item->command = i; break; diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 584604ee63..86572438ec 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -49,7 +49,7 @@ set_fake_editor () { case $line in squash|fixup|edit|reword|drop) action="$line";; - exec*|break) + exec*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; "#") echo '# comment' >> "$1";; diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 185a491089..b282505aac 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -243,7 +243,9 @@ unset GIT_SEQUENCE_EDITOR test_expect_success 'the todo command "break" works' ' rm -f execed && - FAKE_LINES="break exec_>execed" git rebase -i HEAD && + FAKE_LINES="break b exec_>execed" git rebase -i HEAD && + test_path_is_missing execed && + git rebase --continue && test_path_is_missing execed && git rebase --continue && test_path_is_file execed -- 2.19.1.406.g1aa3f475f3 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 3/2] rebase -i: recognize short commands without arguments 2018-10-25 20:47 ` [PATCH 3/2] rebase -i: recognize short commands without arguments Johannes Sixt @ 2018-10-26 1:26 ` Junio C Hamano 2018-10-26 8:04 ` Johannes Schindelin 1 sibling, 0 replies; 27+ messages in thread From: Junio C Hamano @ 2018-10-26 1:26 UTC (permalink / raw) To: Johannes Sixt; +Cc: Johannes Schindelin via GitGitGadget, git, Phillip Wood Johannes Sixt <j6t@kdbg.org> writes: > The sequencer instruction 'b', short for 'break', is rejected: > > error: invalid line 2: b > > The reason is that the parser expects all short commands to have > an argument. Permit short commands without arguments. > > Signed-off-by: Johannes Sixt <j6t@kdbg.org> > --- > I'll send a another patch in a moment that tests all short > sequencer commands, but it is independent from this topic. > > sequencer.c | 3 ++- > t/lib-rebase.sh | 2 +- > t/t3418-rebase-continue.sh | 4 +++- > 3 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/sequencer.c b/sequencer.c > index ee3961ec63..3107f59ea7 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -1954,7 +1954,8 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) > if (skip_prefix(bol, todo_command_info[i].str, &bol)) { > item->command = i; > break; > - } else if (bol[1] == ' ' && *bol == todo_command_info[i].c) { > + } else if ((bol + 1 == eol || bol[1] == ' ') && > + *bol == todo_command_info[i].c) { > bol++; > item->command = i; > break; > diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh > index 584604ee63..86572438ec 100644 > --- a/t/lib-rebase.sh > +++ b/t/lib-rebase.sh > @@ -49,7 +49,7 @@ set_fake_editor () { > case $line in > squash|fixup|edit|reword|drop) > action="$line";; > - exec*|break) > + exec*|break|b) > echo "$line" | sed 's/_/ /g' >> "$1";; > "#") > echo '# comment' >> "$1";; > diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh > index 185a491089..b282505aac 100755 > --- a/t/t3418-rebase-continue.sh > +++ b/t/t3418-rebase-continue.sh > @@ -243,7 +243,9 @@ unset GIT_SEQUENCE_EDITOR > > test_expect_success 'the todo command "break" works' ' > rm -f execed && > - FAKE_LINES="break exec_>execed" git rebase -i HEAD && > + FAKE_LINES="break b exec_>execed" git rebase -i HEAD && > + test_path_is_missing execed && When first 'break' hits, "git rebase -i" shouldn't have exited with non-zero, and we get to see if execed is there (it shouldn't exist yet). > + git rebase --continue && And then we continue, to hit the next 'b', which shouldn't barf, either, and then > test_path_is_missing execed && we make sure execed is not yet there, before continuing out of that that 'b'roken state > git rebase --continue && and then we'll hit the exec to create that file. > test_path_is_file execed Makes sense. Thanks. ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/2] rebase -i: recognize short commands without arguments 2018-10-25 20:47 ` [PATCH 3/2] rebase -i: recognize short commands without arguments Johannes Sixt 2018-10-26 1:26 ` Junio C Hamano @ 2018-10-26 8:04 ` Johannes Schindelin 1 sibling, 0 replies; 27+ messages in thread From: Johannes Schindelin @ 2018-10-26 8:04 UTC (permalink / raw) To: Johannes Sixt Cc: Johannes Schindelin via GitGitGadget, git, Phillip Wood, Junio C Hamano Hi Hannes, On Thu, 25 Oct 2018, Johannes Sixt wrote: > The sequencer instruction 'b', short for 'break', is rejected: > > error: invalid line 2: b > > The reason is that the parser expects all short commands to have > an argument. Permit short commands without arguments. > > Signed-off-by: Johannes Sixt <j6t@kdbg.org> > --- ACK. Thanks for fixing this, Dscho > I'll send a another patch in a moment that tests all short > sequencer commands, but it is independent from this topic. > > sequencer.c | 3 ++- > t/lib-rebase.sh | 2 +- > t/t3418-rebase-continue.sh | 4 +++- > 3 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/sequencer.c b/sequencer.c > index ee3961ec63..3107f59ea7 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -1954,7 +1954,8 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) > if (skip_prefix(bol, todo_command_info[i].str, &bol)) { > item->command = i; > break; > - } else if (bol[1] == ' ' && *bol == todo_command_info[i].c) { > + } else if ((bol + 1 == eol || bol[1] == ' ') && > + *bol == todo_command_info[i].c) { > bol++; > item->command = i; > break; > diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh > index 584604ee63..86572438ec 100644 > --- a/t/lib-rebase.sh > +++ b/t/lib-rebase.sh > @@ -49,7 +49,7 @@ set_fake_editor () { > case $line in > squash|fixup|edit|reword|drop) > action="$line";; > - exec*|break) > + exec*|break|b) > echo "$line" | sed 's/_/ /g' >> "$1";; > "#") > echo '# comment' >> "$1";; > diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh > index 185a491089..b282505aac 100755 > --- a/t/t3418-rebase-continue.sh > +++ b/t/t3418-rebase-continue.sh > @@ -243,7 +243,9 @@ unset GIT_SEQUENCE_EDITOR > > test_expect_success 'the todo command "break" works' ' > rm -f execed && > - FAKE_LINES="break exec_>execed" git rebase -i HEAD && > + FAKE_LINES="break b exec_>execed" git rebase -i HEAD && > + test_path_is_missing execed && > + git rebase --continue && > test_path_is_missing execed && > git rebase --continue && > test_path_is_file execed > -- > 2.19.1.406.g1aa3f475f3 > ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2018-10-26 8:04 UTC | newest] Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-10-03 15:00 [PATCH 0/1] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget 2018-10-03 15:00 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget 2018-10-05 8:15 ` Junio C Hamano 2018-10-05 8:36 ` Jacob Keller 2018-10-05 15:36 ` Johannes Schindelin 2018-10-09 3:59 ` Junio C Hamano 2018-10-09 5:27 ` Junio C Hamano 2018-10-10 8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget 2018-10-10 8:53 ` [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget 2018-10-10 9:46 ` Eric Sunshine 2018-10-11 8:15 ` Junio C Hamano 2018-10-12 8:36 ` Johannes Schindelin 2018-10-10 8:53 ` [PATCH v2 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget 2018-10-11 9:08 ` Phillip Wood 2018-10-12 8:35 ` Johannes Schindelin 2018-10-12 11:09 ` Phillip Wood 2018-10-12 11:24 ` Johannes Schindelin 2018-10-12 13:14 ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget 2018-10-12 13:14 ` [PATCH v3 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget 2018-10-12 14:09 ` Junio C Hamano 2018-10-12 15:31 ` Johannes Schindelin 2018-10-12 14:01 ` [PATCH v3 0/2] " Junio C Hamano 2018-10-12 15:32 ` Johannes Schindelin 2018-10-25 20:47 ` [PATCH 3/2] rebase -i: recognize short commands without arguments Johannes Sixt 2018-10-26 1:26 ` Junio C Hamano 2018-10-26 8:04 ` Johannes Schindelin
Code repositories for project(s) associated with this public inbox https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).