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

[PATCH RFC v2 1/2] builtin/history: refactor function signature

From
Pablo Sabater <pabloosabaterr@gmail.com>
Date
Jun 9, 2026, 10:42 UTC
Message-ID
<20260609-ps-history-reword-v2-1-a0e6028ca9b4@gmail.com>
In-Reply-To
<20260609-ps-history-reword-v2-0-a0e6028ca9b4@gmail.com>

commit_tree_with_edited_message() calls commit_tree_ext() with the flag COMMIT_TREE_EDIT_MESSAGE hardcoded and we can't set new flags on callers like cmd_history_reword() to choose their own flags.

This refactor is needed for a subsequent commit.

Refactor commit_tree_with_edited_message() signature to accept flags which are passed down to commit_tree_ext() instead of the hardcoded one.

Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
---
 builtin/history.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/builtin/history.c b/builtin/history.c
index 0fc06fb204..b3e2e5270d 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -160,7 +160,8 @@ static int commit_tree_ext(struct repository *repo,
 static int commit_tree_with_edited_message(struct repository *repo,
 					   const char *action,
 					   struct commit *original,
-					   struct commit **out)
+					   struct commit **out,
+					   enum commit_tree_flags flags)
 {
 	struct object_id parent_tree_oid;
 	const struct object_id *tree_oid;
@@ -181,7 +182,7 @@ static int commit_tree_with_edited_message(struct repository *repo,
 	}
 
 	return commit_tree_ext(repo, action, original, original->parents,
-			       &parent_tree_oid, tree_oid, out, COMMIT_TREE_EDIT_MESSAGE);
+			       &parent_tree_oid, tree_oid, out, flags);
 }
 
 enum ref_action {
@@ -692,6 +693,7 @@ static int cmd_history_reword(int argc,
 	struct strbuf reflog_msg = STRBUF_INIT;
 	struct commit *original, *rewritten;
 	struct rev_info revs = { 0 };
+	enum commit_tree_flags flags = COMMIT_TREE_EDIT_MESSAGE;
 	int ret;
 
 	argc = parse_options(argc, argv, prefix, options, usage, 0);
@@ -714,7 +716,8 @@ static int cmd_history_reword(int argc,
 	if (ret)
 		goto out;
 
-	ret = commit_tree_with_edited_message(repo, "reworded", original, &rewritten);
+	ret = commit_tree_with_edited_message(repo, "reworded", original,
+					      &rewritten, flags);
 	if (ret < 0) {
 		ret = error(_("failed writing reworded commit"));
 		goto out;
-- 
2.54.0
Previous: Pablo SabaterNext: Pablo Sabater
Message 24 of 36 in “builtin/history: change git history reword behavior and feedback”
  1. 0/2 builtin/history: change git history reword behavior and feedbackPablo Sabater, Jun 7, 2026
  2. 1/2 builtin/history: abort reword on unchanged messagePablo Sabater, Jun 7, 2026
  3. Patrick SteinhardtJun 8, 2026
  4. Pablo SabaterJun 8, 2026
  5. Junio C HamanoJun 8, 2026
  6. Ben KnobleJun 8, 2026
  7. Pablo SabaterJun 9, 2026
  8. Pablo SabaterJun 9, 2026
  9. Kristoffer HaugsbakkJun 9, 2026
  10. Junio C HamanoJun 9, 2026
  11. Pablo SabaterJun 9, 2026
  12. Ben KnobleJun 8, 2026
  13. Pablo SabaterJun 9, 2026
  14. 2/2 builtin/history: print feedback after successful rewordPablo Sabater, Jun 7, 2026
  15. Patrick SteinhardtJun 8, 2026
  16. Pablo SabaterJun 8, 2026
  17. Junio C HamanoJun 8, 2026
  18. Pablo SabaterJun 8, 2026
  19. Ben KnobleJun 8, 2026
  20. Dominique MartinetJul 7, 2026
  21. D. Ben KnobleJul 7, 2026
  22. Patrick SteinhardtJul 8, 2026
  23. 0/2 builtin/history: abort reword on same messagePablo Sabater, Jun 9, 2026
  24. 1/2 builtin/history: refactor function signaturePablo Sabater, Jun 9, 2026
  25. 2/2 builtin/history: abort reword on same messagePablo Sabater, Jun 9, 2026
  26. Phillip WoodJun 9, 2026
  27. Junio C HamanoJun 9, 2026
  28. Pablo SabaterJun 9, 2026
  29. Junio C HamanoJun 9, 2026
  30. Patrick SteinhardtJun 10, 2026
  31. Phillip WoodJun 10, 2026
  32. Junio C HamanoJun 10, 2026
  33. Justin ToblerJun 9, 2026
  34. Junio C HamanoJun 9, 2026
  35. Justin ToblerJun 9, 2026
  36. Phillip WoodJun 10, 2026

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.