Subject: Re: [PATCH v2 3/5] builtin/history: replace "--ref-action=print" with "--dry-run"

From: "Kristoffer Haugsbakk" <[email-masked]>
Date: Fri, 13 Feb 2026 18:30:10 +0100

On Fri, Feb 13, 2026, at 10:12, Patrick Steinhardt wrote:
> The git-history(1) command has the ability to perform a dry-run
> that will not end up modifying any references. Instead, we'll only print
> any ref updates that would happen as a consequence of performing the
> operation.
>
> This mode is somewhat hidden though behind the "--ref-action=print"
> option. This command line option has its origin in git-replay(1), where
> it's probably an okayish interface as this command is sitting more on
> the plumbing side of tools. But git-history(1) is a user-facing tool,
> and this way of achieving a dry-run is way too technical and thus not
> very discoverable.

It makes sense to use this command as a dry run and then pass the output
on to git-update-ref(1) for the wet run.

    git history --dry-run ... | git update-ref --stdin

Looks good.

>
> Besides usability issues, it also has another issue: the dry-run mode
> will always operate as if the user wanted to rewrite all branches. But
> in fact, the user also has the option to only update the HEAD reference,
> and they might want to perform a dry-run of such an operation, too. We
> could of course introduce "--ref-actoin=print-head", but that would

s/--ref-actoin/--ref-action/

> become even less ergonomic.
>
> Replace "--ref-action=print" with a new "--dry-run" toggle. This new
> toggle works with both "--ref-action={head,branches}" and is way more
> discoverable.
>
> Add a test to verify that both "--ref-action=" values behave as
> expected.
>
> This patch is best viewed with "--ignore-space-change".
>
> Signed-off-by: Patrick Steinhardt <[email-masked]>
> ---
>[snip]
> +`--ref-action=(branches|head)`::
>  	Control which references will be updated by the command, if any. With
>  	`branches`, all local branches that point to commits which are
>  	descendants of the original commit will be rewritten. With `head`, only
> -	the current `HEAD` reference will be rewritten. With `print`, all
> -	updates as they would be performed with `branches` are printed in a
> -	format that can be consumed by linkgit:git-update-ref[1].
> +	the current `HEAD` reference will be rewritten.

`HEAD` is mentioned here because it could be detached `HEAD`. So you
can’t just say the current branch.

“the current `HEAD` reference” seems a bit much. Is this less precise?

     only `HEAD` is rewritten.

>  GIT
>  ---
>[snip]