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

"git stash list" shows HEAD reflog

From
VPVladimir Panteleev <vladimir@thecybershadow.net>
Date
Mar 12, 2010, 14:52 UTC
Message-ID
<op.u9gl97fstuzx1w@cybershadow.mshome.net>

I stumbled upon a curious problem with a repository: the command "git stash list" displayed the HEAD reflog instead of the stash list.

The problem was caused by a very long line in ".git/logs/refs/stash". (The stash was based on a commit imported from Subversion, the commit message of which didn't follow git conventions.) The entire line was longer than 1023 characters, which is the buffer size passed to fgets in for_each_recent_reflog_ent. The validation check (buf[len-1] != '\n') causes the line to be skipped. The fix should be simple - if the line read didn't fit in the buffer, add a newline anyway instead of skipping the line entirely.

That doesn't explain why git displayed the HEAD reflog, though. That seems to happen thanks to the check (revs->def && !revs->pending.nr) in setup_revisions ("HEAD" is the default, as specified in the caller cmd_log_init). It looks like (ideally) git shouldn't rely on whether revs->pending is empty to decide whether to use the default, but rather if a ref was specified by the user or not.

-- 
Best regards,
  Vladimir                            mailto:vladimir@thecybershadow.net
Next: René Scharfe
Message 1 of 11 in “"git stash list" shows HEAD reflog”
  1. Vladimir PanteleevMar 12, 2010
  2. René ScharfeMar 13, 2010
  3. Dave OlszewskiMar 13, 2010
  4. René ScharfeMar 13, 2010
  5. Dave OlszewskiMar 13, 2010
  6. René ScharfeMar 13, 2010
  7. don't use default revision if a rev was specifiedDave Olszewski, Mar 13, 2010
  8. René ScharfeMar 13, 2010
  9. Junio C HamanoMar 14, 2010
  10. Pete HarlanMar 13, 2010
  11. René ScharfeMar 13, 2010

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.