Skip to content

Commit 51354d1

Browse files
peffdscho
authored andcommitted
update-ref: do set reflog's old_oid
In git 2.48.1, the `git update-ref` subcommand no longer correctly updates the reflog in some cases. Specifically, it appears that the `old_oid` field will not be updated when modifying a branch referenced by another symbolic ref (e.g. HEAD). This doesn't break the `git reflog` subcommand, but does break references like `HEAD@{1}`, which appear to read the `old_oid` field: git init -b main git commit --allow-empty -m "A" git commit --allow-empty -m "B" git update-ref -m "reason" refs/heads/main HEAD~ HEAD The `old_oid` field is now empty (all zeroes). This is only the case in derived reflogs (in this case .git/logs/HEAD). The reflog for `refs/heads/main` appears to be updated correctly. This was broken in 297c09e (refs: allow multiple reflog entries for the same refname, 2024-12-16). The reason for that was that there was assumed the flow of `lock_ref_for_update()` for reflog only updates was to capture the lock only. But this is wrong since this misses the `old_oid` population. As such this patch is the correct fix. Reported-by: Nika Layzell <nika@thelayzells.com> Acked-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent a2e7060 commit 51354d1

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

Diff for: refs/files-backend.c

-3
Original file line numberDiff line numberDiff line change
@@ -2615,9 +2615,6 @@ static int lock_ref_for_update(struct files_ref_store *refs,
26152615

26162616
update->backend_data = lock;
26172617

2618-
if (update->flags & REF_LOG_ONLY)
2619-
goto out;
2620-
26212618
if (update->type & REF_ISSYMREF) {
26222619
if (update->flags & REF_NO_DEREF) {
26232620
/*

0 commit comments

Comments
 (0)