]> git.ipfire.org Git - thirdparty/git.git/commit
refs: support symrefs in 'reference-transaction' hook
authorKarthik Nayak <karthik.188@gmail.com>
Tue, 7 May 2024 12:58:54 +0000 (14:58 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 May 2024 15:51:49 +0000 (08:51 -0700)
commita8ae923f85da6434c3faf9c39719d6d5e5c77e65
tree28085dadcee71c89bfc4b983107c7744ce8625bd
parent57d0b1e2ea7d133c0ff2461e99c2847fe4ae55e2
refs: support symrefs in 'reference-transaction' hook

The 'reference-transaction' hook runs whenever a reference update is
made to the system. In a previous commit, we added the `old_target` and
`new_target` fields to the `reference_transaction_update()`. In
following commits we'll also add the code to handle symref's in the
reference backends.

Support symrefs also in the 'reference-transaction' hook, by modifying
the current format:
    <old-oid> SP <new-oid> SP <ref-name> LF
to be be:
    <old-value> SP <new-value> SP <ref-name> LF
where for regular refs the output would not change and remain the same.
But when either 'old-value' or 'new-value' is a symref, we print the ref
as 'ref:<ref-target>'.

This does break backward compatibility, but the 'reference-transaction'
hook's documentation always stated that support for symbolic references
may be added in the future.

We do not add any tests in this commit since there is no git command
which activates this flow, in an upcoming commit, we'll start using
transaction based symref updates as the default, we'll add tests there
for the hook too.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/githooks.txt
refs.c