]> git.ipfire.org Git - thirdparty/git.git/commit
update-ref: add support for 'symref-delete' command
authorKarthik Nayak <karthik.188@gmail.com>
Fri, 7 Jun 2024 13:33:01 +0000 (15:33 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Jun 2024 17:25:44 +0000 (10:25 -0700)
commit2343720967aac3725148e1a6690dbe6c98fe5f2e
tree38b682117482317d7e3ffcc743734a6f6b9225e3
parent1451ac734ffc1b9c45af12a2485c6d2ee69a6a76
update-ref: add support for 'symref-delete' command

Add a new command 'symref-delete' to allow deletions of symbolic refs in
a transaction via the '--stdin' mode of the 'git-update-ref' command.
The 'symref-delete' command can, when given an <old-target>, delete the
provided <ref> only when it points to <old-target>.

This command is only compatible with the 'no-deref' mode because we
optionally want to check the 'old_target' of the ref being deleted.
De-referencing a symbolic ref would provide a regular ref and we already
have the 'delete' command for regular refs.

While users can also use 'git symbolic-ref -d' to delete symbolic refs,
the 'symref-delete' command in 'git-update-ref' allows users to do so
within a transaction, which promises atomicity of the operation and can
be batched with other commands.

When no 'old_target' is provided it can also delete regular refs,
similar to how the 'delete' command can delete symrefs when no 'old_oid'
is provided.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-update-ref.txt
builtin/fetch.c
builtin/receive-pack.c
builtin/update-ref.c
refs.c
refs.h
t/t1400-update-ref.sh
t/t1416-ref-transaction-hooks.sh