mbox series

[v3,0/2] rebase -i: introduce the 'break' command

Message ID pull.43.v3.git.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series rebase -i: introduce the 'break' command | expand

Message

Johannes Schindelin via GitGitGadget Oct. 12, 2018, 1:14 p.m. UTC
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))

Comments

Junio C Hamano Oct. 12, 2018, 2:01 p.m. UTC | #1
"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.
Johannes Schindelin Oct. 12, 2018, 3:32 p.m. UTC | #2
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.
>