git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alban Gruin <alban.gruin@gmail.com>
To: Phillip Wood <phillip.wood@dunelm.org.uk>,
	Git Mailing List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [RFC PATCH 08/11] rebase -i: use struct rebase_options to parse args
Date: Thu, 21 Mar 2019 22:13:11 +0100	[thread overview]
Message-ID: <7ba0dc1a-b6dd-4ef6-81ee-495e32fc67cf@gmail.com> (raw)
In-Reply-To: <20190319190317.6632-9-phillip.wood123@gmail.com>

Hi Phillip,

It’s nice to see your work on this on the list.

Le 19/03/2019 à 20:03, Phillip Wood a écrit :
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
> 
> In order to run `rebase -i` without forking `rebase--interactive` it
> will be convenient to use the same structure when parsing the options in
> cmd_rebase() and cmd_rebase__interactive().
> 
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>  builtin/rebase.c | 203 ++++++++++++++++++++++++++---------------------
>  1 file changed, 112 insertions(+), 91 deletions(-)
> 
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index c93f2aa629..33a2495032 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -50,6 +50,73 @@ enum rebase_type {
>  	REBASE_PRESERVE_MERGES
>  };
>  
> +struct rebase_options {
> +	enum rebase_type type;
> +	const char *state_dir;
> +	struct commit *upstream;
> +	const char *upstream_name;
> +	const char *upstream_arg;
> +	char *head_name;
> +	struct object_id orig_head;
> +	struct commit *onto;
> +	const char *onto_name;
> +	const char *revisions;
> +	const char *switch_to;
> +	int root;
> +	struct object_id *squash_onto;
> +	struct commit *restrict_revision;
> +	int dont_finish_rebase;
> +	enum {
> +		REBASE_NO_QUIET = 1<<0,
> +		REBASE_VERBOSE = 1<<1,
> +		REBASE_DIFFSTAT = 1<<2,
> +		REBASE_FORCE = 1<<3,
> +		REBASE_INTERACTIVE_EXPLICIT = 1<<4,
> +	} flags;
> +	struct argv_array git_am_opts;
> +	const char *action;
> +	int signoff;
> +	int allow_rerere_autoupdate;
> +	int keep_empty;
> +	int autosquash;
> +	char *gpg_sign_opt;
> +	int autostash;
> +	char *cmd;
> +	int allow_empty_message;
> +	int rebase_merges, rebase_cousins;
> +	char *strategy, *strategy_opts;
> +	struct strbuf git_format_patch_opt;
> +	int reschedule_failed_exec;
> +};
> +
> +#define REBASE_OPTIONS_INIT {			  	\
> +		.type = REBASE_UNSPECIFIED,	  	\
> +		.flags = REBASE_NO_QUIET, 		\
> +		.git_am_opts = ARGV_ARRAY_INIT,		\
> +		.git_format_patch_opt = STRBUF_INIT	\
> +	}
> +
> +static struct replay_opts get_replay_opts(const struct rebase_options *opts)
> +{
> +	struct replay_opts replay = REPLAY_OPTS_INIT;
> +
> +	sequencer_init_config(&replay);
> +
> +	replay.action = REPLAY_INTERACTIVE_REBASE;
> +	replay.signoff = opts->signoff;
> +	replay.allow_ff = !(opts->flags & REBASE_FORCE);
> +	if (opts->allow_rerere_autoupdate)
> +		replay.allow_rerere_auto = opts->allow_rerere_autoupdate;
> +	replay.allow_empty = 1;
> +	replay.allow_empty_message = opts->allow_empty_message;
> +	replay.verbose = opts->flags & REBASE_VERBOSE;
> +	replay.reschedule_failed_exec = opts->reschedule_failed_exec;
> +	replay.gpg_sign = xstrdup_or_null(opts->gpg_sign_opt);
> +	replay.strategy = opts->strategy;
> +
> +	return replay;
> +}
> +

I wonder if `struct rebase_options` and `struct replay_options` could be
merged, or at least have `replay_options` used in `rebase_options`,
instead of converting one to the other.  I think it would make things
simpler and cleaner, but I don’t know how hard it would be, or if my
assumption is correct.

Cheers,
Alban


  parent reply	other threads:[~2019-03-21 21:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 19:03 [RFC PATCH 00/11] rebase -i run without forking rebase--interactive Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 01/11] sequencer: always discard index after checkout Phillip Wood
2019-03-20  1:50   ` Duy Nguyen
2019-03-21 14:35     ` Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 02/11] rebase: rename write_basic_state() Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 03/11] rebase: use OPT_RERERE_AUTOUPDATE() Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 04/11] rebase -i: combine rebase--interactive.c with rebase.c Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 05/11] rebase -i: remove duplication Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 06/11] rebase -i: use struct commit when parsing options Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 07/11] rebase -i: use struct object_id for squash_onto Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 08/11] rebase -i: use struct rebase_options to parse args Phillip Wood
2019-03-21  4:21   ` Junio C Hamano
2019-03-21 14:59     ` Phillip Wood
2019-03-22  3:34       ` Junio C Hamano
2019-03-21 21:13   ` Alban Gruin [this message]
2019-04-10 19:16     ` Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 09/11] rebase -i: use struct rebase_options in do_interactive_rebase() Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 10/11] rebase: use a common action enum Phillip Wood
2019-03-19 20:24   ` Ævar Arnfjörð Bjarmason
2019-03-21 14:43     ` Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 11/11] rebase -i: run without forking rebase--interactive Phillip Wood
2019-03-20 20:50 ` [RFC PATCH 00/11] rebase -i " Josh Steadmon
2019-03-20 23:05 ` Ævar Arnfjörð Bjarmason
2019-03-21 14:40   ` Phillip Wood
2019-03-21  1:44 ` Junio C Hamano
2019-04-17 14:30 ` [PATCH v1 00/12] Run rebase -i " Phillip Wood
2019-04-17 14:30   ` [PATCH v1 01/12] sequencer: always discard index after checkout Phillip Wood
2019-04-17 14:30   ` [PATCH v1 02/12] rebase: don't translate trace strings Phillip Wood
2019-04-19  5:53     ` Junio C Hamano
2019-04-25 17:47       ` Phillip Wood
2019-04-17 14:30   ` [PATCH v1 03/12] rebase: rename write_basic_state() Phillip Wood
2019-04-17 14:30   ` [PATCH v1 04/12] rebase: use OPT_RERERE_AUTOUPDATE() Phillip Wood
2019-04-17 14:30   ` [PATCH v1 05/12] rebase -i: combine rebase--interactive.c with rebase.c Phillip Wood
2019-04-17 14:30   ` [PATCH v1 06/12] rebase -i: remove duplication Phillip Wood
2019-04-17 14:30   ` [PATCH v1 07/12] rebase -i: use struct commit when parsing options Phillip Wood
2019-04-17 14:30   ` [PATCH v1 08/12] rebase -i: use struct object_id for squash_onto Phillip Wood
2019-04-17 14:30   ` [PATCH v1 09/12] rebase -i: use struct rebase_options to parse args Phillip Wood
2019-04-17 14:30   ` [PATCH v1 10/12] rebase -i: use struct rebase_options in do_interactive_rebase() Phillip Wood
2019-04-17 14:30   ` [PATCH v1 11/12] rebase: use a common action enum Phillip Wood
2019-04-17 14:30   ` [PATCH v1 12/12] rebase -i: run without forking rebase--interactive Phillip Wood

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=7ba0dc1a-b6dd-4ef6-81ee-495e32fc67cf@gmail.com \
    --to=alban.gruin@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    /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).