Skip to content

Commit 1ffd2d4

Browse files
pks-tgitster
authored andcommitted
refs: export ref_transaction_update_reflog()
In a subsequent commit we'll add another user that wants to write reflog entries. This requires them to call `ref_transaction_update_reflog()`, but that function is local to "refs.c". Export the function to prepare for the change. While at it, drop the `flags` field, as all callers are for now expected to use the same flags anyway. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 649c7bb commit 1ffd2d4

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

refs.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,27 +1371,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
13711371
return 0;
13721372
}
13731373

1374-
/*
1375-
* Similar to`ref_transaction_update`, but this function is only for adding
1376-
* a reflog update. Supports providing custom committer information. The index
1377-
* field can be utiltized to order updates as desired. When not used, the
1378-
* updates default to being ordered by refname.
1379-
*/
1380-
static int ref_transaction_update_reflog(struct ref_transaction *transaction,
1381-
const char *refname,
1382-
const struct object_id *new_oid,
1383-
const struct object_id *old_oid,
1384-
const char *committer_info,
1385-
unsigned int flags,
1386-
const char *msg,
1387-
uint64_t index,
1388-
struct strbuf *err)
1374+
int ref_transaction_update_reflog(struct ref_transaction *transaction,
1375+
const char *refname,
1376+
const struct object_id *new_oid,
1377+
const struct object_id *old_oid,
1378+
const char *committer_info,
1379+
const char *msg,
1380+
uint64_t index,
1381+
struct strbuf *err)
13891382
{
13901383
struct ref_update *update;
1384+
unsigned int flags;
13911385

13921386
assert(err);
13931387

1394-
flags |= REF_LOG_ONLY | REF_FORCE_CREATE_REFLOG | REF_NO_DEREF;
1388+
flags = REF_HAVE_OLD | REF_HAVE_NEW | REF_LOG_ONLY | REF_FORCE_CREATE_REFLOG | REF_NO_DEREF;
13951389

13961390
if (!transaction_refname_valid(refname, new_oid, flags, err))
13971391
return -1;
@@ -3019,8 +3013,7 @@ static int migrate_one_reflog_entry(struct object_id *old_oid,
30193013

30203014
ret = ref_transaction_update_reflog(data->transaction, data->refname,
30213015
new_oid, old_oid, data->sb->buf,
3022-
REF_HAVE_NEW | REF_HAVE_OLD, msg,
3023-
data->index++, data->errbuf);
3016+
msg, data->index++, data->errbuf);
30243017
return ret;
30253018
}
30263019

refs.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
795795
unsigned int flags, const char *msg,
796796
struct strbuf *err);
797797

798+
/*
799+
* Similar to `ref_transaction_update`, but this function is only for adding
800+
* a reflog update. Supports providing custom committer information. The index
801+
* field can be utiltized to order updates as desired. When set to zero, the
802+
* updates default to being ordered by refname.
803+
*/
804+
int ref_transaction_update_reflog(struct ref_transaction *transaction,
805+
const char *refname,
806+
const struct object_id *new_oid,
807+
const struct object_id *old_oid,
808+
const char *committer_info,
809+
const char *msg,
810+
uint64_t index,
811+
struct strbuf *err);
812+
798813
/*
799814
* Add a reference creation to transaction. new_oid is the value that
800815
* the reference should have after the update; it must not be

0 commit comments

Comments
 (0)