git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [RFC PATCH 03/11] rebase: use OPT_RERERE_AUTOUPDATE()
Date: Tue, 19 Mar 2019 19:03:09 +0000	[thread overview]
Message-ID: <20190319190317.6632-4-phillip.wood123@gmail.com> (raw)
In-Reply-To: <20190319190317.6632-1-phillip.wood123@gmail.com>

From: Phillip Wood <phillip.wood@dunelm.org.uk>

As we have a macro for this it makes sense to use it. Having
cmd_rebase() and cmd_rebase__interactive() use the same values for
this option will be helpful when we start running interactive rebases
without forking rebase--interactive.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 builtin/rebase.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/builtin/rebase.c b/builtin/rebase.c
index b634879c5b..ccf178326c 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -206,14 +206,13 @@ static int read_basic_state(struct rebase_options *opts)
 			    &buf))
 			return -1;
 		if (!strcmp(buf.buf, "--rerere-autoupdate"))
-			opts->allow_rerere_autoupdate = 1;
+			opts->allow_rerere_autoupdate = RERERE_AUTOUPDATE;
 		else if (!strcmp(buf.buf, "--no-rerere-autoupdate"))
-			opts->allow_rerere_autoupdate = 0;
+			opts->allow_rerere_autoupdate = RERERE_NOAUTOUPDATE;
 		else
 			warning(_("ignoring invalid allow_rerere_autoupdate: "
 				  "'%s'"), buf.buf);
-	} else
-		opts->allow_rerere_autoupdate = -1;
+	}
 
 	if (file_exists(state_dir_path("gpg_sign_opt", opts))) {
 		strbuf_reset(&buf);
@@ -263,10 +262,11 @@ static int rebase_write_basic_state(struct rebase_options *opts)
 	if (opts->strategy_opts)
 		write_file(state_dir_path("strategy_opts", opts), "%s",
 			   opts->strategy_opts);
-	if (opts->allow_rerere_autoupdate >= 0)
+	if (opts->allow_rerere_autoupdate > 0)
 		write_file(state_dir_path("allow_rerere_autoupdate", opts),
 			   "-%s-rerere-autoupdate",
-			   opts->allow_rerere_autoupdate ? "" : "-no");
+			   opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
+				"" : "-no");
 	if (opts->gpg_sign_opt)
 		write_file(state_dir_path("gpg_sign_opt", opts), "%s",
 			   opts->gpg_sign_opt);
@@ -625,9 +625,9 @@ static int run_am(struct rebase_options *opts)
 	argv_array_push(&am.args, "--rebasing");
 	argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
 	argv_array_push(&am.args, "--patch-format=mboxrd");
-	if (opts->allow_rerere_autoupdate > 0)
+	if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
 		argv_array_push(&am.args, "--rerere-autoupdate");
-	else if (opts->allow_rerere_autoupdate == 0)
+	else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
 		argv_array_push(&am.args, "--no-rerere-autoupdate");
 	if (opts->gpg_sign_opt)
 		argv_array_push(&am.args, opts->gpg_sign_opt);
@@ -713,9 +713,9 @@ static int run_specific_rebase(struct rebase_options *opts)
 			argv_array_pushf(&child.args, "--cmd=%s", opts->cmd);
 		if (opts->allow_empty_message)
 			argv_array_push(&child.args, "--allow-empty-message");
-		if (opts->allow_rerere_autoupdate > 0)
+		if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
 			argv_array_push(&child.args, "--rerere-autoupdate");
-		else if (opts->allow_rerere_autoupdate == 0)
+		else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
 			argv_array_push(&child.args, "--no-rerere-autoupdate");
 		if (opts->gpg_sign_opt)
 			argv_array_push(&child.args, opts->gpg_sign_opt);
@@ -764,9 +764,9 @@ static int run_specific_rebase(struct rebase_options *opts)
 	add_var(&script_snippet, "action", opts->action ? opts->action : "");
 	add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
 	add_var(&script_snippet, "allow_rerere_autoupdate",
-		opts->allow_rerere_autoupdate < 0 ? "" :
 		opts->allow_rerere_autoupdate ?
-		"--rerere-autoupdate" : "--no-rerere-autoupdate");
+			opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
+			"--rerere-autoupdate" : "--no-rerere-autoupdate" : "");
 	add_var(&script_snippet, "keep_empty", opts->keep_empty ? "yes" : "");
 	add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : "");
 	add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt);
@@ -1007,7 +1007,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		.type = REBASE_UNSPECIFIED,
 		.flags = REBASE_NO_QUIET,
 		.git_am_opts = ARGV_ARRAY_INIT,
-		.allow_rerere_autoupdate  = -1,
 		.allow_empty_message = 1,
 		.git_format_patch_opt = STRBUF_INIT,
 	};
@@ -1102,10 +1101,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		OPT_SET_INT('p', "preserve-merges", &options.type,
 			    N_("try to recreate merges instead of ignoring "
 			       "them"), REBASE_PRESERVE_MERGES),
-		OPT_BOOL(0, "rerere-autoupdate",
-			 &options.allow_rerere_autoupdate,
-			 N_("allow rerere to update index with resolved "
-			    "conflict")),
+		OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
 		OPT_BOOL('k', "keep-empty", &options.keep_empty,
 			 N_("preserve empty commits during rebase")),
 		OPT_BOOL(0, "autosquash", &options.autosquash,
-- 
2.21.0


  parent reply	other threads:[~2019-03-19 19:04 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 ` Phillip Wood [this message]
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
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=20190319190317.6632-4-phillip.wood123@gmail.com \
    --to=phillip.wood123@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).