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

Re: [PATCH 1/3] builtin/history: sign rewritten commits

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 16, 2026, 10:18 UTC
Message-ID
<aliv3zgfDvY3JoB9@pks.im>
In-Reply-To
<20260703145037.69832-2-git@5ouma.me>
On Fri, Jul 03, 2026 at 11:50:35PM +0900, Souma wrote:
Show 19 quoted lines
> diff --git a/builtin/history.c b/builtin/history.c
> index 091465a59e..8d669cf539 100644
> --- a/builtin/history.c
> +++ b/builtin/history.c
> @@ -98,6 +98,30 @@ enum commit_tree_flags {
>  	COMMIT_TREE_EDIT_MESSAGE = (1 << 0),
>  };
>  
> +static int history_config(const char *var, const char *value,
> +			  const struct config_context *ctx, void *data)
> +{
> +	const char **sign_commit = data;
> +
> +	if (!strcmp(var, "commit.gpgsign")) {
> +		*sign_commit = git_config_bool(var, value) ? "" : NULL;
> +		return 0;
> +	}
> +
> +	return git_default_config(var, value, ctx, data);

Shouldn't we rather pass `NULL` instead of `data`? It works, sure, but only because `git_default_config()` doesn't use `data` at all.

Show 7 quoted lines
> @@ -160,7 +185,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,
> +					   const char *sign_commit)
Nit: the `out` parameter should continue to be the last one.
Show 15 quoted lines
> @@ -515,12 +546,13 @@ static int cmd_history_fixup(int argc,
>  	bool skip_commit = false;
>  	int ret;
>  
> +	repo_config(repo, history_config, &sign_commit);
> +
>  	argc = parse_options(argc, argv, prefix, options, usage, 0);
>  	if (argc != 1) {
>  		ret = error(_("command expects a single revision"));
>  		goto out;
>  	}
> -	repo_config(repo, git_default_config, NULL);
>  
>  	if (action == REF_ACTION_DEFAULT)
>  		action = REF_ACTION_BRANCHES;

It might make sense to document in the commit message why we have to change the order. I guess it's because of precedence, but not everyone might realize that immediately.

Show 10 quoted lines
> @@ -785,7 +822,8 @@ static int write_ondisk_index(struct repository *repo,
>  static int split_commit(struct repository *repo,
>  			struct commit *original,
>  			struct pathspec *pathspec,
> -			struct commit **out)
> +			struct commit **out,
> +			const char *sign_commit)
>  {
>  	struct interactive_options interactive_opts = INTERACTIVE_OPTIONS_INIT;
>  	struct strbuf index_file = STRBUF_INIT;
Likewise, let's ensure that the `out` parameter remains last.
> diff --git a/replay.c b/replay.c
> index da531d5bc6..683c384ef8 100644
> --- a/replay.c
> +++ b/replay.c

It might make sense to split out the changes to "replay.c" into a preparatory commit.

One interesting question is whether it really makes sense to sign _all_ commits. It's rather likely that the history will contain commits that aren't even owned by you, so signing them with your signature might be a bit of a weird choice. I guess that might be okay-ish, but it's certainly something that's worth a discussion as part of the commit message.

Thanks!
Patrick
Previous: SoumaNext: Souma
Message 3 of 30 in “history: sign rewritten commits”
  1. 0/3 history: sign rewritten commitsSouma, Jul 3, 2026
  2. 1/3 builtin/history: sign rewritten commitsSouma, Jul 3, 2026
  3. Patrick SteinhardtJul 16, 2026
  4. 2/3 doc: document history signing optionsSouma, Jul 3, 2026
  5. Patrick SteinhardtJul 16, 2026
  6. 3/3 t345x: cover signed history rewritesSouma, Jul 3, 2026
  7. 0/2 history: support signing rewritten commitsSouma, Jul 17, 2026
  8. 1/2 replay: allow callers to sign commitsSouma, Jul 17, 2026
  9. Patrick SteinhardtSep 11, 2026
  10. 2/2 builtin/history: sign rewritten commitsSouma, Jul 17, 2026
  11. Patrick SteinhardtSep 11, 2026
  12. 0/2 history: support signing rewritten commitsSouma, Sep 12, 2026
  13. 1/2 replay: allow callers to sign commitsSouma, Sep 12, 2026
  14. Patrick SteinhardtSep 28, 2026
  15. 2/2 history: sign rewritten commitsSouma, Sep 12, 2026
  16. Patrick SteinhardtSep 28, 2026
  17. Junio C HamanoSep 28, 2026
  18. Junio C HamanoSep 28, 2026
  19. SoumaSep 28, 2026
  20. 0/2 history: sign rewritten commitsSouma, Oct 2, 2026
  21. Junio C HamanoOct 2, 2026
  22. SoumaOct 3, 2026
  23. 1/2 replay: allow callers to sign commitsSouma, Oct 2, 2026
  24. 2/2 history: sign rewritten commitsSouma, Oct 2, 2026
  25. 0/2 history: sign rewritten commitsSouma, Oct 3, 2026
  26. Junio C HamanoOct 4, 2026
  27. SoumaOct 5, 2026
  28. Junio C HamanoOct 6, 2026
  29. 1/2 replay: allow callers to sign commitsSouma, Oct 3, 2026
  30. 2/2 history: sign rewritten commitsSouma, Oct 3, 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.