[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