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

Re: [BUG] `git gc` or `git pack-refs` wipes all notes for `git notes` command

From
Jeff King <peff@peff.net>
Date
Jan 3, 2023, 09:04 UTC
Message-ID
<Y7Pvqk00sj3R7cZv@coredump.intra.peff.net>
In-Reply-To
<CAAYtLELp4v=id-UUdGT+BoCxLuTV05Z0fFMQmPfd3Mt-yXJ9Tw@mail.gmail.com>
On Tue, Jan 03, 2023 at 05:22:01AM +0200, Andrew Hlynskyi wrote:
Show 5 quoted lines
> Steps to reproduce:
> 1. Create some notes with the `git notes add` command.
> 2. Run `git notes` to list stored notes.
> 3. Run any of `git gc  --prune=now` or `git pack-refs --all` commands.
> 4. Run `git notes` again and see that there are no more seen notes.
This doesn't reproduce for me at all. Running:
  git init repo
  cd repo
  git commit --allow-empty -m "this is the commit message"
  git notes add -m "this is the note"
  git notes
  git pack-refs --all
  git notes
Shows the same output before and after packing the refs.
> The reason is that all commands like `git notes` or `git log --notes`
> expect to find notes head as unpacked ref in .git/refs/notes/commits.
> But the gc or the pack-refs command packs .git/refs/notes/commits ref
> into .git/packed-refs file.

That would be very surprising. The lookup of the ref in the notes code uses the same generic ref code that the rest of Git uses, which understands packed-refs and so on.

Can you share the .git directory of a repository that exhibits this behavior? It's possible there's a bug or something in the packed-refs code, though I find it pretty unlikely, as it's fairly well exercised in normal use.

-Peff
Previous: Andrew HlynskyiNext: Andrew Hlynskyi
Message 2 of 6 in “[BUG] `git gc` or `git pack-refs` wipes all notes for `git notes` command”
  1. Andrew HlynskyiJan 3, 2023
  2. Jeff KingJan 3, 2023
  3. Andrew HlynskyiJan 5, 2023
  4. Jeff KingJan 6, 2023
  5. Junio C HamanoJan 6, 2023
  6. Jeff KingJan 6, 2023

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.