Merge branch 'ps/reflog-migrate-fixes' into ps/remote-rename-fix

* ps/reflog-migrate-fixes:
  refs: fix invalid old object IDs when migrating reflogs
  refs: stop unsetting REF_HAVE_OLD for log-only updates
  refs/files: detect race when generating reflog entry for HEAD
  refs: fix identity for migrated reflogs
  ident: fix type of string length parameter
  builtin/reflog: implement subcommand to write new entries
  refs: export `ref_transaction_update_reflog()`
  builtin/reflog: improve grouping of subcommands
  Documentation/git-reflog: convert to use synopsis type
This commit is contained in:
Junio C Hamano
2025-08-06 07:41:57 -07:00
12 changed files with 446 additions and 150 deletions

24
refs.h
View File

@@ -759,13 +759,20 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
*/
#define REF_SKIP_CREATE_REFLOG (1 << 12)
/*
* When writing a REF_LOG_ONLY record, use the old and new object IDs provided
* in the update instead of resolving the old object ID. The caller must also
* set both REF_HAVE_OLD and REF_HAVE_NEW.
*/
#define REF_LOG_USE_PROVIDED_OIDS (1 << 13)
/*
* Bitmask of all of the flags that are allowed to be passed in to
* ref_transaction_update() and friends:
*/
#define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \
(REF_NO_DEREF | REF_FORCE_CREATE_REFLOG | REF_SKIP_OID_VERIFICATION | \
REF_SKIP_REFNAME_VERIFICATION | REF_SKIP_CREATE_REFLOG)
REF_SKIP_REFNAME_VERIFICATION | REF_SKIP_CREATE_REFLOG | REF_LOG_USE_PROVIDED_OIDS)
/*
* Add a reference update to transaction. `new_oid` is the value that
@@ -794,6 +801,21 @@ int ref_transaction_update(struct ref_transaction *transaction,
unsigned int flags, const char *msg,
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
* the reference should have after the update; it must not be