git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Andrei Rybak <rybak.a.v@gmail.com>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk,
	predatoramigo@gmail.com
Subject: [RFC PATCH v2 2/4] rebase: prepare cmd before choosing action
Date: Wed, 20 Nov 2019 10:52:36 +0100	[thread overview]
Message-ID: <20191120095238.4349-3-rybak.a.v@gmail.com> (raw)
In-Reply-To: <20191114163549.7648-1-rybak.a.v@gmail.com>

When git rebase is started with option --exec, its arguments are parsed
into string_list exec and then converted into options.cmd.

In following commits, action --edit-todo will be taught to use arguments
passed with --exec option.  Prepare options.cmd before switch (action)
to make it available for the ACTION_EDIT_TODO branch of the switch.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
---
 builtin/rebase.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/builtin/rebase.c b/builtin/rebase.c
index 793cac1386..fa27f7b439 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1595,6 +1595,19 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			trace2_cmd_mode(action_names[action]);
 	}
 
+	for (i = 0; i < exec.nr; i++)
+		if (check_exec_cmd(exec.items[i].string))
+			exit(1);
+
+	if (exec.nr) {
+		imply_interactive(&options, "--exec");
+
+		strbuf_reset(&buf);
+		for (i = 0; i < exec.nr; i++)
+			strbuf_addf(&buf, "exec %s\n", exec.items[i].string);
+		options.cmd = xstrdup(buf.buf);
+	}
+
 	switch (action) {
 	case ACTION_CONTINUE: {
 		struct object_id head;
@@ -1731,10 +1744,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	for (i = 0; i < exec.nr; i++)
-		if (check_exec_cmd(exec.items[i].string))
-			exit(1);
-
 	if (!(options.flags & REBASE_NO_QUIET))
 		argv_array_push(&options.git_am_opts, "-q");
 
@@ -1746,15 +1755,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		options.gpg_sign_opt = xstrfmt("-S%s", gpg_sign);
 	}
 
-	if (exec.nr) {
-		imply_interactive(&options, "--exec");
-
-		strbuf_reset(&buf);
-		for (i = 0; i < exec.nr; i++)
-			strbuf_addf(&buf, "exec %s\n", exec.items[i].string);
-		options.cmd = xstrdup(buf.buf);
-	}
-
 	if (rebase_merges) {
 		if (!*rebase_merges)
 			; /* default mode; do nothing */
-- 
2.24.0.windows.2


  parent reply	other threads:[~2019-11-20  9:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14 16:35 [PATCH 0/3] rebase --edit-todo --exec Andrei Rybak
2019-11-14 16:35 ` [PATCH 1/3] rebase: prepare cmd before choosing action Andrei Rybak
2019-11-15  5:49   ` Junio C Hamano
2019-11-14 16:35 ` [PATCH 2/3] rebase: extract add_exec() Andrei Rybak
2019-11-14 16:35 ` [PATCH 3/3] rebase -i: allow --edit-todo with --exec Andrei Rybak
2019-11-20  9:52 ` [RFC PATCH v2 0/4] rebase --edit-todo --exec Andrei Rybak
2019-11-20  9:52 ` [RFC PATCH v2 1/4] builtin/rebase.c: reuse loop variable Andrei Rybak
2019-11-21  1:30   ` Junio C Hamano
2019-11-20  9:52 ` Andrei Rybak [this message]
2019-11-21  2:00   ` [RFC PATCH v2 2/4] rebase: prepare cmd before choosing action Junio C Hamano
2019-11-22 19:08     ` Andrei Rybak
2019-11-20  9:52 ` [RFC PATCH v2 3/4] rebase: extract add_exec() Andrei Rybak
2019-11-20  9:52 ` [RFC PATCH v2 4/4] rebase -i: allow --edit-todo with --exec Andrei Rybak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191120095238.4349-3-rybak.a.v@gmail.com \
    --to=rybak.a.v@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=predatoramigo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).