refs: fix invalid old object IDs when migrating reflogs
When migrating reflog entries between different storage formats we end up with invalid old object IDs for the migrated entries: instead of writing the old object ID of the to-be-migrated entry, we end up with the all-zeroes object ID. The root cause of this issue is that we don't know to use the old object ID provided by the caller. Instead, we manually resolve the old object ID by resolving the current value of its matching reference. But as that reference does not yet exist in the target ref storage we always end up resolving it to all-zeroes. This issue got unnoticed as there is no user-facing command that would even show the old object ID. While `git log -g` knows to show the new object ID, we don't have any formatting directive to show the old object ID. Fix the bug by introducing a new flag `REF_LOG_USE_PROVIDED_OIDS`. If set, backends are instructed to use the old and new object IDs provided by the caller, without doing any manual resolving. Set this flag in `ref_transaction_update_reflog()`. Amend our tests in t1460-refs-migrate to use our test tool to read reflog entries. This test tool prints out both old and new object ID of each reflog entry, which fixes the test gap. Furthermore it also prints the full identity used to write the reflog, which provides test coverage for the previous commit in this patch series that fixed the identity for migrated reflogs. 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
046c67325c
commit
465eff81de
9
refs.h
9
refs.h
@@ -760,13 +760,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
|
||||
|
||||
Reference in New Issue
Block a user