From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] update-ref: add --rename option
Date: Fri, 12 Jun 2026 08:00:10 +0200 [thread overview]
Message-ID: <aiugat0gvprSX5yr@pks.im> (raw)
In-Reply-To: <xmqq7bo4n4ge.fsf@gitster.g>
On Thu, Jun 11, 2026 at 02:37:53PM -0700, Junio C Hamano wrote:
> Add a "--rename" option to "git update-ref" with the syntax:
>
> $ git update-ref --rename <old-refname> <new-refname>
>
> It renames <old-refname> together with its reflog to <new-refname>;
> even when used on a local branch ref, the current value and the
> reflog of the ref are the only things that are renamed. Document it
> and redirect casual users to "git branch -m" if that is what they
> wanted to do.
This reads much better, thanks.
> diff --git a/Documentation/git-update-ref.adoc b/Documentation/git-update-ref.adoc
> index 37a5019a8b..3b4df23a86 100644
> --- a/Documentation/git-update-ref.adoc
> +++ b/Documentation/git-update-ref.adoc
> @@ -9,6 +9,7 @@ SYNOPSIS
> --------
> [synopsis]
> git update-ref [-m <reason>] [--no-deref] -d <ref> [<old-oid>]
> +git update-ref [-m <reason>] --rename <old-refname> <new-refname>
> git update-ref [-m <reason>] [--no-deref] [--create-reflog] <ref> <new-oid> [<old-oid>]
> git update-ref [-m <reason>] [--no-deref] --stdin [-z] [--batch-updates]
This slightly triggers my OCD, but oh, well. No need to change this.
> diff --git a/builtin/update-ref.c b/builtin/update-ref.c
> index 2d68c40ecb..65ee8af08c 100644
> --- a/builtin/update-ref.c
> +++ b/builtin/update-ref.c
> @@ -800,6 +802,32 @@ int cmd_update_ref(int argc,
> if (end_null)
> usage_with_options(git_update_ref_usage, options);
>
> + if (rename) {
> + const char *oldref, *newref;
> +
> + if (delete || argc != 2)
> + usage_with_options(git_update_ref_usage, options);
Arguably, we should also complain when either "--no-deref" or "--deref"
were given, as they don't have any effect.
A slight tangent: this is part of why I really don't like commands that
determine their mode via flags: you now have to worry about every
combination of flags and whether they even make sense. With subcommands
we at least only have to worry about the set of flags that directly
apply to that given subcommand.
Makes me wonder whether I should have a look at extending git-refs(1)
further:
git refs delete <ref> [<oldvalue>]
git refs update <ref> <newvalue> [<oldvalue>]
git refs rename <ref> <oldname> <newname>
I always wanted to do this eventually so that we have one top-level
command that knows how to do "everything refs".
Anyway, except for this nit the patch looks good to me, thanks!
Patrick
prev parent reply other threads:[~2026-06-12 6:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 21:35 [PATCH] update-ref: add --rename option Junio C Hamano
2026-06-10 21:28 ` [PATCH v2] " Junio C Hamano
2026-06-11 13:05 ` Patrick Steinhardt
2026-06-11 18:47 ` Junio C Hamano
2026-06-12 6:04 ` Patrick Steinhardt
2026-06-11 21:37 ` [PATCH v3] " Junio C Hamano
2026-06-12 6:00 ` Patrick Steinhardt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiugat0gvprSX5yr@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox