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

Re: [PATCH 0/3] symref rename/delete fixes

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 27, 2008, 05:31 UTC
Message-ID
<7vhc6yioyq.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<cover.1224987944.git.vmiklos@frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> writes:
Show 7 quoted lines
> A symref-aware rename_ref() is needed by git remove rename, since it
> typically does origin/HEAD -> upstream/HEAD symref renames there.
>
> Of course you can say that this should be handled by git-remote itself,
> without using rename_ref() but that not seem to be a good solution to
> me. (Workaround in the wrong layer, instead of a solution in a good
> one.)
I do not think it is a workaround at all.

I would even say that the renaming of symref that "git remote rename" needs to do is fundamentally different from what rename_ref() is about, and trying to cram it into rename_ref() is a grave mistake.

If you "git remote rename origin upstream" when origin/HEAD points at refs/remotes/origin/master, you need to make the renamed one point at refs/remotes/upstream/master, as you will be renaming origin/master to upstream/master.

Normal "rename_ref()" would just rename the ref without touching its contents, and if you used it to implement "git remote rename", your upstream/HEAD would point at the old name "origin/master" that will disappear when rename is finished, wouldn't it? I do not think it is useful.

There may be cases where you would really want to rename the symbolic ref without changing its value (e.g. which other ref it points at), but as you mentioned, even "git branch -m" is not such a usecase.

I think it is better to simply forbid renaming of a symref _until_ we know what we want it to mean. It is a lot easier to start strict and then add features, than start loosely and implement an unclean semantics, and then having to fix that semantics after people start to rely on the initial (potentially crazy) semantics.

Previous: Miklos VajnaNext: Miklos Vajna
Message 5 of 6 in “symref rename/delete fixes”
  1. 0/3 symref rename/delete fixesMiklos Vajna, Oct 26, 2008
  2. 1/3 Fix git branch -m for symrefs.Miklos Vajna, Oct 26, 2008
  3. 2/3 rename_ref(): handle the case when the reflog of a ref does not existMiklos Vajna, Oct 26, 2008
  4. 3/3 Fix git update-ref --no-deref -d.Miklos Vajna, Oct 26, 2008
  5. Junio C HamanoOct 27, 2008
  6. Miklos VajnaOct 27, 2008

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.