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

[PATCH v4 1/5] rebase: stop reading and writing unnecessary strategy state

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 10, 2023, 09:08 UTC
Message-ID
<882b403423e5c2d90c3afc4eefb02bb499c4a02b.1681117706.git.phillip.wood@dunelm.org.uk>
In-Reply-To
<cover.1681117706.git.phillip.wood@dunelm.org.uk>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

The state files for "--strategy" and "--strategy-option" are written and read twice, once by builtin/rebase.c and then by sequencer.c. This is an artifact of the scripted rebase and the need to support "rebase --preserve-merges". Now that "--preserve-merges" no-longer exists we only need to read and write these files in sequencer.c. This enables us to remove a call to free() in read_strategy_opts() that was added by f1f4ebf432 (sequencer.c: fix "opts->strategy" leak in read_strategy_opts(), 2022-11-08) as this commit fixes the root cause of that leak.

There is further scope for removing duplication in the reading and writing of state files between builtin/rebase.c and sequencer.c but that is left for a follow up series.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 builtin/rebase.c | 24 ------------------------
 sequencer.c      |  1 -
 2 files changed, 25 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 5b7b908b66..3bd215c771 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -483,24 +483,6 @@ static int read_basic_state(struct rebase_options *opts)
 		opts->gpg_sign_opt = xstrdup(buf.buf);
 	}
 
-	if (file_exists(state_dir_path("strategy", opts))) {
-		strbuf_reset(&buf);
-		if (!read_oneliner(&buf, state_dir_path("strategy", opts),
-				   READ_ONELINER_WARN_MISSING))
-			return -1;
-		free(opts->strategy);
-		opts->strategy = xstrdup(buf.buf);
-	}
-
-	if (file_exists(state_dir_path("strategy_opts", opts))) {
-		strbuf_reset(&buf);
-		if (!read_oneliner(&buf, state_dir_path("strategy_opts", opts),
-				   READ_ONELINER_WARN_MISSING))
-			return -1;
-		free(opts->strategy_opts);
-		opts->strategy_opts = xstrdup(buf.buf);
-	}
-
 	strbuf_release(&buf);
 
 	return 0;
@@ -518,12 +500,6 @@ static int rebase_write_basic_state(struct rebase_options *opts)
 		write_file(state_dir_path("quiet", opts), "%s", "");
 	if (opts->flags & REBASE_VERBOSE)
 		write_file(state_dir_path("verbose", opts), "%s", "");
-	if (opts->strategy)
-		write_file(state_dir_path("strategy", opts), "%s",
-			   opts->strategy);
-	if (opts->strategy_opts)
-		write_file(state_dir_path("strategy_opts", opts), "%s",
-			   opts->strategy_opts);
 	if (opts->allow_rerere_autoupdate > 0)
 		write_file(state_dir_path("allow_rerere_autoupdate", opts),
 			   "-%s-rerere-autoupdate",
diff --git a/sequencer.c b/sequencer.c
index 3be23d7ca2..c35a67e104 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2944,7 +2944,6 @@ static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf)
 	strbuf_reset(buf);
 	if (!read_oneliner(buf, rebase_path_strategy(), 0))
 		return;
-	free(opts->strategy);
 	opts->strategy = strbuf_detach(buf, NULL);
 	if (!read_oneliner(buf, rebase_path_strategy_opts(), 0))
 		return;
-- 
2.40.0.672.gbd2d2ac924
Previous: Phillip WoodNext: Phillip Wood
Message 31 of 36 in “rebase: cleanup merge strategy option handling”
  1. 0/4 rebase: cleanup merge strategy option handlingPhillip Wood, Mar 15, 2023
  2. 1/4 rebase: stop reading and writing unnecessary strategy statePhillip Wood, Mar 15, 2023
  3. 2/4 rebase -m: cleanup --strategy-option handlingPhillip Wood, Mar 15, 2023
  4. 3/4 rebase -m: fix serialization of strategy optionsPhillip Wood, Mar 15, 2023
  5. Elijah NewrenApr 1, 2023
  6. Phillip WoodApr 4, 2023
  7. 4/4 rebase: remove a couple of redundant strategy testsPhillip Wood, Mar 15, 2023
  8. Elijah NewrenApr 1, 2023
  9. Phillip WoodApr 4, 2023
  10. Junio C HamanoMar 15, 2023
  11. Felipe ContrerasMar 15, 2023
  12. Elijah NewrenApr 1, 2023
  13. 0/5 rebase: cleanup merge strategy option handlingPhillip Wood, Apr 5, 2023
  14. 1/5 rebase: stop reading and writing unnecessary strategy statePhillip Wood, Apr 5, 2023
  15. 3/5 rebase -m: cleanup --strategy-option handlingPhillip Wood, Apr 5, 2023
  16. 2/5 sequencer: use struct strvec to store merge strategy optionsPhillip Wood, Apr 5, 2023
  17. Elijah NewrenApr 7, 2023
  18. 4/5 rebase -m: fix serialization of strategy optionsPhillip Wood, Apr 5, 2023
  19. Elijah NewrenApr 7, 2023
  20. 5/5 rebase: remove a couple of redundant strategy testsPhillip Wood, Apr 5, 2023
  21. Elijah NewrenApr 7, 2023
  22. Phillip WoodApr 7, 2023
  23. Junio C HamanoApr 7, 2023
  24. 0/5 rebase: cleanup merge strategy option handlingPhillip Wood, Apr 7, 2023
  25. 1/5 rebase: stop reading and writing unnecessary strategy statePhillip Wood, Apr 7, 2023
  26. 2/5 sequencer: use struct strvec to store merge strategy optionsPhillip Wood, Apr 7, 2023
  27. 3/5 rebase -m: cleanup --strategy-option handlingPhillip Wood, Apr 7, 2023
  28. 4/5 rebase -m: fix serialization of strategy optionsPhillip Wood, Apr 7, 2023
  29. 5/5 rebase: remove a couple of redundant strategy testsPhillip Wood, Apr 7, 2023
  30. 0/5 rebase: cleanup merge strategy option handlingPhillip Wood, Apr 10, 2023
  31. 1/5 rebase: stop reading and writing unnecessary strategy statePhillip Wood, Apr 10, 2023
  32. 3/5 rebase -m: cleanup --strategy-option handlingPhillip Wood, Apr 10, 2023
  33. 2/5 sequencer: use struct strvec to store merge strategy optionsPhillip Wood, Apr 10, 2023
  34. 4/5 rebase -m: fix serialization of strategy optionsPhillip Wood, Apr 10, 2023
  35. 5/5 rebase: remove a couple of redundant strategy testsPhillip Wood, Apr 10, 2023
  36. Elijah NewrenApr 10, 2023

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.