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

Re: [PATCH 3/4] builtin/refs: add "update" subcommand

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 17, 2026, 07:28 UTC
Message-ID
<ajJMpH7VQY3Hxm9A@pks.im>
In-Reply-To
<xmqqse6m4jw4.fsf@gitster.g>
On Tue, Jun 16, 2026 at 07:52:59AM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> >  git refs delete [--message=<reason>] [--no-deref] <ref> [<oldvalue>]
> > +git refs update [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value> [<old-value>]
> 
> "<old-value> vs <new-value>" is good, we should update "delete" to
> use "<old-value>" to match.
Good catch.
Show 15 quoted lines
> > @@ -58,6 +59,12 @@ delete::
> >  	reference is only deleted after verifying that it currently contains
> >  	`<oldvalue>`.
> >  
> > +update::
> > +	Update the given reference to point at `<new-value>`. This subcommand
> > +	mirrors `git update-ref` (see linkgit:git-update-ref[1]). When
> > +	`<old-value>` is given, the reference is only updated after verifying
> > +	that it currently contains `<old-value>`.
> 
> As to the lack of "create", among the two potential changes, I have
> a slight preference for adding "create" and failing "update" that
> does not refer to an existing ref.  If we go that route, the
> "--create-reflog" option should move to "create", as "update" will
> never be used to create a new ref.

I agree that we should add "create", but I also think that we should keep the special syntax of:

  - "git refs update $NULL_OID [$OLD_OID]" to delete a branch.
  - "git refs update $NEW_OID $NULL_OID" to create a branch.

While the other commands are more ergonomic, I don't see a strong reason to restrict the "update" subcommand. Also, this ensures that it's in line with git-update-ref(1), which also allows for these use cases.

Show 13 quoted lines
> > +	if (repo_get_oid_with_flags(repo, argv[1], &newoid,
> > +				    GET_OID_SKIP_AMBIGUITY_CHECK))
> > +		die(_("invalid new object ID: %s"), argv[1]);
> > +	if (argc == 3 &&
> > +	    repo_get_oid_with_flags(repo, argv[2], &oldoid,
> > +				    GET_OID_SKIP_AMBIGUITY_CHECK))
> > +		die(_("invalid old object ID: %s"), argv[2]);
> 
> On the "delete" side, these messages quote the object name, i.e.,
> 
> 			die(_("invalid old object ID: '%s'"), argv[1]);
> 
> We should be consistent.
Yup, fixed now.
Patrick
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 9 of 47 in “builtin/refs: add ability to write references”
  1. 0/4 builtin/refs: add ability to write referencesPatrick Steinhardt, Jun 16, 2026
  2. 1/4 builtin/refs: drop `the_repository`Patrick Steinhardt, Jun 16, 2026
  3. 2/4 builtin/refs: add "delete" subcommandPatrick Steinhardt, Jun 16, 2026
  4. 3/4 builtin/refs: add "update" subcommandPatrick Steinhardt, Jun 16, 2026
  5. Junio C HamanoJun 16, 2026
  6. Patrick SteinhardtJun 17, 2026
  7. Junio C HamanoJun 17, 2026
  8. Junio C HamanoJun 16, 2026
  9. Patrick SteinhardtJun 17, 2026
  10. 4/4 builtin/refs: add "rename" subcommandPatrick Steinhardt, Jun 16, 2026
  11. Junio C HamanoJun 16, 2026
  12. Patrick SteinhardtJun 17, 2026
  13. Junio C HamanoJun 17, 2026
  14. 0/5 builtin/refs: add ability to write referencesPatrick Steinhardt, Jun 17, 2026
  15. 1/5 builtin/refs: drop `the_repository`Patrick Steinhardt, Jun 17, 2026
  16. 2/5 builtin/refs: add "delete" subcommandPatrick Steinhardt, Jun 17, 2026
  17. 3/5 builtin/refs: add "update" subcommandPatrick Steinhardt, Jun 17, 2026
  18. 4/5 builtin/refs: add "create" subcommandPatrick Steinhardt, Jun 17, 2026
  19. Junio C HamanoJun 29, 2026
  20. Patrick SteinhardtJun 30, 2026
  21. 5/5 builtin/refs: add "rename" subcommandPatrick Steinhardt, Jun 17, 2026
  22. Junio C HamanoJun 17, 2026
  23. Junio C HamanoJun 29, 2026
  24. Patrick SteinhardtJun 30, 2026
  25. 0/5 builtin/refs: add ability to write referencesPatrick Steinhardt, Jun 30, 2026
  26. 1/5 builtin/refs: drop `the_repository`Patrick Steinhardt, Jun 30, 2026
  27. 2/5 builtin/refs: add "delete" subcommandPatrick Steinhardt, Jun 30, 2026
  28. Toon ClaesJul 3, 2026
  29. Patrick SteinhardtJul 3, 2026
  30. 3/5 builtin/refs: add "update" subcommandPatrick Steinhardt, Jun 30, 2026
  31. 4/5 builtin/refs: add "create" subcommandPatrick Steinhardt, Jun 30, 2026
  32. Toon ClaesJul 3, 2026
  33. Patrick SteinhardtJul 6, 2026
  34. Toon ClaesJul 9, 2026
  35. Toon ClaesJul 9, 2026
  36. 5/5 builtin/refs: add "rename" subcommandPatrick Steinhardt, Jun 30, 2026
  37. Toon ClaesJul 3, 2026
  38. Patrick SteinhardtJul 6, 2026
  39. Junio C HamanoJun 30, 2026
  40. 0/5 builtin/refs: add ability to write referencesPatrick Steinhardt, Jul 6, 2026
  41. 1/5 builtin/refs: drop `the_repository`Patrick Steinhardt, Jul 6, 2026
  42. 2/5 builtin/refs: add "delete" subcommandPatrick Steinhardt, Jul 6, 2026
  43. Toon ClaesJul 9, 2026
  44. 3/5 builtin/refs: add "update" subcommandPatrick Steinhardt, Jul 6, 2026
  45. 4/5 builtin/refs: add "create" subcommandPatrick Steinhardt, Jul 6, 2026
  46. 5/5 builtin/refs: add "rename" subcommandPatrick Steinhardt, Jul 6, 2026
  47. Junio C HamanoJul 6, 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.