git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* `git update-ref` fails to set reflog old_oid in 2.48
@ 2025-01-21 20:40 Nika Layzell
  2025-01-21 21:52 ` Jeff King
  0 siblings, 1 reply; 13+ messages in thread
From: Nika Layzell @ 2025-01-21 20:40 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-01-24 10:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-21 20:40 `git update-ref` fails to set reflog old_oid in 2.48 Nika Layzell
2025-01-21 21:52 ` Jeff King
2025-01-22  6:47   ` Karthik Nayak
2025-01-22 10:03   ` [PATCH] refs: fix creation of corrupted reflogs for symrefs Karthik Nayak
2025-01-22 12:04     ` Patrick Steinhardt
2025-01-22 17:56       ` Junio C Hamano
2025-01-23 10:21       ` Karthik Nayak
2025-01-22 15:02     ` Jeff King
2025-01-23 11:08       ` Karthik Nayak
2025-01-23 14:34         ` Jeff King
2025-01-23 11:29     ` [PATCH v2] " Karthik Nayak
2025-01-23 17:55       ` Junio C Hamano
2025-01-24 10:38         ` Karthik Nayak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).