git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1 04/12] rebase: use OPT_RERERE_AUTOUPDATE()

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 17, 2019, 14:30 UTC
Message-ID
<20190417143044.17655-5-phillip.wood123@gmail.com>
In-Reply-To
<20190417143044.17655-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 0b1a193a8e..e7b8122003 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,
 	};
@@ -1101,10 +1100,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
Previous: Phillip WoodNext: Phillip Wood
Message 29 of 40 in “rebase -i run without forking rebase--interactive”
  1. 00/11 rebase -i run without forking rebase--interactivePhillip Wood, Mar 19, 2019
  2. 02/11 rebase: rename write_basic_state()Phillip Wood, Mar 19, 2019
  3. 01/11 sequencer: always discard index after checkoutPhillip Wood, Mar 19, 2019
  4. Duy NguyenMar 20, 2019
  5. Phillip WoodMar 21, 2019
  6. 03/11 rebase: use OPT_RERERE_AUTOUPDATE()Phillip Wood, Mar 19, 2019
  7. 05/11 rebase -i: remove duplicationPhillip Wood, Mar 19, 2019
  8. 06/11 rebase -i: use struct commit when parsing optionsPhillip Wood, Mar 19, 2019
  9. 04/11 rebase -i: combine rebase--interactive.c with rebase.cPhillip Wood, Mar 19, 2019
  10. 07/11 rebase -i: use struct object_id for squash_ontoPhillip Wood, Mar 19, 2019
  11. 08/11 rebase -i: use struct rebase_options to parse argsPhillip Wood, Mar 19, 2019
  12. Junio C HamanoMar 21, 2019
  13. Phillip WoodMar 21, 2019
  14. Junio C HamanoMar 22, 2019
  15. Alban GruinMar 21, 2019
  16. Phillip WoodApr 10, 2019
  17. 10/11 rebase: use a common action enumPhillip Wood, Mar 19, 2019
  18. Ævar Arnfjörð BjarmasonMar 19, 2019
  19. Phillip WoodMar 21, 2019
  20. 09/11 rebase -i: use struct rebase_options in do_interactive_rebase()Phillip Wood, Mar 19, 2019
  21. 11/11 rebase -i: run without forking rebase--interactivePhillip Wood, Mar 19, 2019
  22. Josh SteadmonMar 20, 2019
  23. Ævar Arnfjörð BjarmasonMar 20, 2019
  24. Phillip WoodMar 21, 2019
  25. Junio C HamanoMar 21, 2019
  26. 00/12 Run rebase -i without forking rebase--interactivePhillip Wood, Apr 17, 2019
  27. 01/12 sequencer: always discard index after checkoutPhillip Wood, Apr 17, 2019
  28. 03/12 rebase: rename write_basic_state()Phillip Wood, Apr 17, 2019
  29. 04/12 rebase: use OPT_RERERE_AUTOUPDATE()Phillip Wood, Apr 17, 2019
  30. 02/12 rebase: don't translate trace stringsPhillip Wood, Apr 17, 2019
  31. Junio C HamanoApr 19, 2019
  32. Phillip WoodApr 25, 2019
  33. 05/12 rebase -i: combine rebase--interactive.c with rebase.cPhillip Wood, Apr 17, 2019
  34. 06/12 rebase -i: remove duplicationPhillip Wood, Apr 17, 2019
  35. 08/12 rebase -i: use struct object_id for squash_ontoPhillip Wood, Apr 17, 2019
  36. 07/12 rebase -i: use struct commit when parsing optionsPhillip Wood, Apr 17, 2019
  37. 09/12 rebase -i: use struct rebase_options to parse argsPhillip Wood, Apr 17, 2019
  38. 10/12 rebase -i: use struct rebase_options in do_interactive_rebase()Phillip Wood, Apr 17, 2019
  39. 12/12 rebase -i: run without forking rebase--interactivePhillip Wood, Apr 17, 2019
  40. 11/12 rebase: use a common action enumPhillip Wood, Apr 17, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.