]> git.ipfire.org Git - thirdparty/git.git/commit
refs: don't invoke reference-transaction hook for reflogs
authorKarthik Nayak <karthik.188@gmail.com>
Thu, 14 Nov 2024 09:58:35 +0000 (10:58 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Nov 2024 23:48:23 +0000 (08:48 +0900)
commitb886db48c61bdfb817f29482e18120c4fa2bc89c
tree3ecd0e093db255353976585e909e7b70361427b7
parent777489f9e09c8d0dd6b12f9d90de6376330577a2
refs: don't invoke reference-transaction hook for reflogs

The reference-transaction hook is invoked whenever there is a reference
update being performed. For each state of the transaction, we iterate
over the updates present and pass this information to the hook.

The `ref_update` structure is used to hold these updates within a
`transaction`. We use the same structure for holding reflog updates too.
Which means that the reference transaction hook is also obtaining
information about a reflog update. This is a bug, since:

  - The hook is designed to work with reference updates and reflogs
  updates are different.
  - The hook doesn't have the required information to distinguish
  reference updates from reflog updates.

This is particularly evident when the default branch (pointed by HEAD)
is updated, we see that the hook also receives information about HEAD
being changed. In reality, we only add a reflog update for HEAD, while
HEAD's values remains the same.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
t/t1416-ref-transaction-hooks.sh