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

Re: create reflog for reflog-less ref

From
Jeff King <peff@peff.net>
Date
Feb 26, 2020, 18:40 UTC
Message-ID
<20200226184038.GB23188@coredump.intra.peff.net>
In-Reply-To
<CAOTb1weTWOsHkbGqmj8mJ-KpkoiteHBDYDxe-j2E0yf3DccjjQ@mail.gmail.com>
On Wed, Feb 26, 2020 at 02:21:59AM -0800, Chris Jerdonek wrote:
Show 17 quoted lines
> > The "touch" trick I showed would work for that, but it's not going to be
> > portable going forward. I don't think it would be a bad idea to have
> > some way of triggering a "noop" reflog update via update-ref, where we
> > either create the reflog as empty, or insert a pointless entry going
> > from the current sha1 to itself. But AFAIK that doesn't exist right now.
> 
> Thanks. By the way, this functionality does already seem to exist for ref HEAD:
> 
> $ git update-ref -m my-message HEAD HEAD
> $ git reflog HEAD
> 3ccacdc (HEAD -> master) HEAD@{0}: my-message
> ...
> 
> I don't know why it would work for HEAD though and what's different
> about the mechanism. I thought it might be because it's a symbolic
> ref, but it didn't work for other symbolic refs when I tried (even
> ones that already had a reflog).

I suspect that wasn't really intentional, but just a by-product of the way we treat HEAD's reflog specially (when we update any other ref, if HEAD points to it, we'll update the HEAD reflog, too). But I could be wrong (you'd have to dig in the commit history around that code).

-Peff
Previous: Chris Jerdonek
Message 7 of 7 in “create reflog for reflog-less ref”
  1. Chris JerdonekFeb 26, 2020
  2. brian m. carlsonFeb 26, 2020
  3. Jeff KingFeb 26, 2020
  4. Chris JerdonekFeb 26, 2020
  5. Jeff KingFeb 26, 2020
  6. Chris JerdonekFeb 26, 2020
  7. Jeff KingFeb 26, 2020

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.