Do not call the reference-transaction hooks for reflogs
❯ cat .git/hooks/reference-transaction
#!/bin/bash
# Print basic information about the transaction
echo "Reference transaction: $1"
# Read through the input and print each line
while read old_value new_value ref_name; do
echo "Old value: $old_value"
echo "New value: $new_value"
echo "Reference name: $ref_name"
done
# Exit with 0 to allow the operation to continue
exit 0
❯ git branch
b1 * master
❯ git update-ref refs/heads/master @~1
Reference transaction: prepared
Old value: 0000000000000000000000000000000000000000
New value: ac85d08c3dc0c73d5a6db5a21686645353cacd0c
Reference name: refs/heads/master
Old value: 0000000000000000000000000000000000000000
New value: ac85d08c3dc0c73d5a6db5a21686645353cacd0c
Reference name: HEAD
Reference transaction: committed
Old value: 0000000000000000000000000000000000000000
New value: ac85d08c3dc0c73d5a6db5a21686645353cacd0c
Reference name: refs/heads/master
Old value: 0000000000000000000000000000000000000000
New value: ac85d08c3dc0c73d5a6db5a21686645353cacd0c
Reference name: HEAD
Notice how the reference-transaction hook also printed out HEAD, eventhough HEAD never changed (always pointed at refs/heads/master). This is because we add reflog entry for HEAD whenever the ref it is pointing to changes. However, currently changes to reflog also trigger the reference-transaction hook. This is a bug and should be fixed.