mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
649c7bb77a
commit
1ffd2d4159
29
refs.c
29
refs.c
@@ -1371,27 +1371,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int ref_transaction_update_reflog(struct ref_transaction *transaction,
|
||||||
* Similar to`ref_transaction_update`, but this function is only for adding
|
const char *refname,
|
||||||
* a reflog update. Supports providing custom committer information. The index
|
const struct object_id *new_oid,
|
||||||
* field can be utiltized to order updates as desired. When not used, the
|
const struct object_id *old_oid,
|
||||||
* updates default to being ordered by refname.
|
const char *committer_info,
|
||||||
*/
|
const char *msg,
|
||||||
static int ref_transaction_update_reflog(struct ref_transaction *transaction,
|
uint64_t index,
|
||||||
const char *refname,
|
struct strbuf *err)
|
||||||
const struct object_id *new_oid,
|
|
||||||
const struct object_id *old_oid,
|
|
||||||
const char *committer_info,
|
|
||||||
unsigned int flags,
|
|
||||||
const char *msg,
|
|
||||||
uint64_t index,
|
|
||||||
struct strbuf *err)
|
|
||||||
{
|
{
|
||||||
struct ref_update *update;
|
struct ref_update *update;
|
||||||
|
unsigned int flags;
|
||||||
|
|
||||||
assert(err);
|
assert(err);
|
||||||
|
|
||||||
flags |= REF_LOG_ONLY | REF_FORCE_CREATE_REFLOG | REF_NO_DEREF;
|
flags = REF_HAVE_OLD | REF_HAVE_NEW | REF_LOG_ONLY | REF_FORCE_CREATE_REFLOG | REF_NO_DEREF;
|
||||||
|
|
||||||
if (!transaction_refname_valid(refname, new_oid, flags, err))
|
if (!transaction_refname_valid(refname, new_oid, flags, err))
|
||||||
return -1;
|
return -1;
|
||||||
@@ -3019,8 +3013,7 @@ static int migrate_one_reflog_entry(struct object_id *old_oid,
|
|||||||
|
|
||||||
ret = ref_transaction_update_reflog(data->transaction, data->refname,
|
ret = ref_transaction_update_reflog(data->transaction, data->refname,
|
||||||
new_oid, old_oid, data->sb->buf,
|
new_oid, old_oid, data->sb->buf,
|
||||||
REF_HAVE_NEW | REF_HAVE_OLD, msg,
|
msg, data->index++, data->errbuf);
|
||||||
data->index++, data->errbuf);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
refs.h
15
refs.h
@@ -795,6 +795,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
|
|||||||
unsigned int flags, const char *msg,
|
unsigned int flags, const char *msg,
|
||||||
struct strbuf *err);
|
struct strbuf *err);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Similar to `ref_transaction_update`, but this function is only for adding
|
||||||
|
* a reflog update. Supports providing custom committer information. The index
|
||||||
|
* field can be utiltized to order updates as desired. When set to zero, the
|
||||||
|
* updates default to being ordered by refname.
|
||||||
|
*/
|
||||||
|
int ref_transaction_update_reflog(struct ref_transaction *transaction,
|
||||||
|
const char *refname,
|
||||||
|
const struct object_id *new_oid,
|
||||||
|
const struct object_id *old_oid,
|
||||||
|
const char *committer_info,
|
||||||
|
const char *msg,
|
||||||
|
uint64_t index,
|
||||||
|
struct strbuf *err);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a reference creation to transaction. new_oid is the value that
|
* Add a reference creation to transaction. new_oid is the value that
|
||||||
* the reference should have after the update; it must not be
|
* the reference should have after the update; it must not be
|
||||||
|
|||||||
Reference in New Issue
Block a user