refs: allow to skip creation of reflog entries

The ref backends do not have any way to disable the creation of reflog
entries. This will be required for upcoming ref format migration logic
so that we do not create any entries that didn't exist in the original
ref database.

Provide a new `REF_SKIP_CREATE_REFLOG` flag that allows the caller to
disable reflog entry creation.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-06-06 07:29:11 +02:00
committed by Junio C Hamano
parent 6e1683ace9
commit fbd1a693c7
5 changed files with 20 additions and 2 deletions

View File

@ -1750,6 +1750,9 @@ static int files_log_ref_write(struct files_ref_store *refs,
{
int logfd, result;
if (flags & REF_SKIP_CREATE_REFLOG)
return 0;
if (log_all_ref_updates == LOG_REFS_UNSET)
log_all_ref_updates = is_bare_repository() ? LOG_REFS_NONE : LOG_REFS_NORMAL;
@ -2251,6 +2254,7 @@ static int split_head_update(struct ref_update *update,
struct ref_update *new_update;
if ((update->flags & REF_LOG_ONLY) ||
(update->flags & REF_SKIP_CREATE_REFLOG) ||
(update->flags & REF_IS_PRUNING) ||
(update->flags & REF_UPDATE_VIA_HEAD))
return 0;