From: Junio C Hamano Date: Tue, 16 Jun 2026 11:17:27 GMT Subject: Re: [PATCH 3/4] builtin/refs: add "update" subcommand Message-ID: In-Reply-To: <20260616-pks-refs-writing-subcommands-v1-3-9f5219b6109d@pks.im> Patrick Steinhardt writes: > Add a new "update" subcommand which mirrors `git update-ref > `. This follows the same reasoning as the preceding > commit. > > Signed-off-by: Patrick Steinhardt > --- > Documentation/git-refs.adoc | 7 ++ > builtin/refs.c | 50 +++++++++++++ > t/meson.build | 1 + > t/t1465-refs-update.sh | 179 ++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 237 insertions(+) I do not offhand know (and I am still away by 2 hours from the time I wake up and start functioning) if update-ref shares the same issue, but with "delete, update, rename" combo, lack of "create" feels a bit annoying. Wouldn't we want to offer an option to users who want to ensure that the refs they create are truly new and they are not overwriting a ref somebody has created? Either (1) drop "delete" and take a special value (e.g. "") as to signal deletion and make the same special value used as signals creation, or (2) add "create" and insist that "update" takes only an existing ref, would make the annoyance go away, I guess. > +test_expect_success 'update creates a new reference' ' > + test_when_finished "rm -rf repo" && > + setup_repo repo && > + ( > + cd repo && > + A=$(git rev-parse A) && > + git refs update refs/heads/foo $A && > + test_ref_matches refs/heads/foo "$A" > + ) > +' Here we cannot test (and I strongly suspect that "git refs update" and "git update-ref" lack ability to do so) a case where a creation is attempted on an existing ref and fails.