From: Andrei Rybak <rybak.a.v@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 2/3] rebase: extract add_exec()
Date: Thu, 14 Nov 2019 17:35:48 +0100 [thread overview]
Message-ID: <20191114163549.7648-3-rybak.a.v@gmail.com> (raw)
In-Reply-To: <20191114163549.7648-1-rybak.a.v@gmail.com>
In following commit addition of commands to the todo file will be
implemented for the --edit-todo action. So extract a function to avoid
duplicating the code for splitting of opts->cmd into list of commands.
Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
---
builtin/rebase.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 9457912f9d..27507d3cf6 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -299,6 +299,17 @@ static void split_exec_commands(const char *cmd, struct string_list *commands)
}
}
+static int add_exec(const char *cmd)
+{
+ struct string_list commands = STRING_LIST_INIT_DUP;
+ int ret;
+
+ split_exec_commands(cmd, &commands);
+ ret = add_exec_commands(&commands);
+ string_list_clear(&commands, 0);
+ return ret;
+}
+
static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
{
int ret;
@@ -420,11 +431,7 @@ static int run_rebase_interactive(struct rebase_options *opts,
ret = rearrange_squash_in_todo_file();
break;
case ACTION_ADD_EXEC: {
- struct string_list commands = STRING_LIST_INIT_DUP;
-
- split_exec_commands(opts->cmd, &commands);
- ret = add_exec_commands(&commands);
- string_list_clear(&commands, 0);
+ ret = add_exec(opts->cmd);
break;
}
default:
--
2.24.0.windows.2
next prev parent reply other threads:[~2019-11-14 16:35 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 ` Andrei Rybak [this message]
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 ` [RFC PATCH v2 2/4] rebase: prepare cmd before choosing action Andrei Rybak
2019-11-21 2:00 ` 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=20191114163549.7648-3-rybak.a.v@gmail.com \
--to=rybak.a.v@gmail.com \
--cc=git@vger.kernel.org \
/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).