git/list[1] front-page[2] threads[3] people[4] search[5] about
 

`git update-ref` fails to set reflog old_oid in 2.48

From
Nika Layzell <nika@thelayzells.com>
Date
Jan 21, 2025, 20:40 UTC
Message-ID
<CACwGqKixQEGau8CZuLwJx02F4h8hxrf9e_7N1tHMU=Wvy8ViyQ@mail.gmail.com>

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.

STR (in a fresh directory): ``` 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 ```

Expected Result: ``` $ git rev-parse HEAD@{1} 70d9116663eee9f01065c3a6d8984b1dea661f20

$ cat .git/logs/HEAD 0000000000000000000000000000000000000000 17dd31aaf89190a36b8d04136a1a0f83fb37da4c AUTHOR <EMAIL> TIME commit (initial): A 17dd31aaf89190a36b8d04136a1a0f83fb37da4c 70d9116663eee9f01065c3a6d8984b1dea661f20 AUTHOR <EMAIL> TIME commit: B 70d9116663eee9f01065c3a6d8984b1dea661f20 17dd31aaf89190a36b8d04136a1a0f83fb37da4c AUTHOR <EMAIL> TIME reason ```

The `old_oid` field for the reflog entry added by `git update-ref` is present, and correctly initialized. This was the case prior to git 2.48.

Actual Result: ``` $ git rev-parse HEAD@{1} warning: log for ref HEAD unexpectedly ended on TIME 17dd31aaf89190a36b8d04136a1a0f83fb37da4c

$ cat .git/logs/HEAD 0000000000000000000000000000000000000000 17dd31aaf89190a36b8d04136a1a0f83fb37da4c AUTHOR <EMAIL> TIME commit (initial): A 17dd31aaf89190a36b8d04136a1a0f83fb37da4c 70d9116663eee9f01065c3a6d8984b1dea661f20 AUTHOR <EMAIL> TIME commit: B 0000000000000000000000000000000000000000 17dd31aaf89190a36b8d04136a1a0f83fb37da4c AUTHOR <EMAIL> TIME reason ```

The `old_oid` field is 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.

Next: Jeff King
Message 1 of 13 in “`git update-ref` fails to set reflog old_oid in 2.48”
  1. Nika LayzellJan 21, 2025
  2. Jeff KingJan 21, 2025
  3. Karthik NayakJan 22, 2025
  4. refs: fix creation of corrupted reflogs for symrefsKarthik Nayak, Jan 22, 2025
  5. Patrick SteinhardtJan 22, 2025
  6. Junio C HamanoJan 22, 2025
  7. Karthik NayakJan 23, 2025
  8. Jeff KingJan 22, 2025
  9. Karthik NayakJan 23, 2025
  10. Jeff KingJan 23, 2025
  11. refs: fix creation of corrupted reflogs for symrefsKarthik Nayak, Jan 23, 2025
  12. Junio C HamanoJan 23, 2025
  13. Karthik NayakJan 24, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.