git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] `git gc` or `git pack-refs` wipes all notes for `git notes` command
@ 2023-01-03  3:22 Andrew Hlynskyi
  2023-01-03  9:04 ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Hlynskyi @ 2023-01-03  3:22 UTC (permalink / raw)
  To: git

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.

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.

It's possible to restore the notes ref with a shell script like:
```
fix-notes-unpack-commits-ref(){
    local hash path
    grep refs/notes/commits .git/packed-refs |\
    while read hash path; do
        path=".git/$path"
        mkdir -p "$(dirname "$path")"
        echo -n "$hash" > "$path"
    done
}
```
Or, fortunately, from another backup place: .git/logs/refs/notes/commits.

The expected behavior is that `git notes` and `git log` should work
also with notes ref stored in the .git/packed-refs file and also
respect that the `git notes` command can store notes with a custom ref
by using the `--ref` option.

Yours sincerely,
Andrew

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

end of thread, other threads:[~2023-01-06 13:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03  3:22 [BUG] `git gc` or `git pack-refs` wipes all notes for `git notes` command Andrew Hlynskyi
2023-01-03  9:04 ` Jeff King
2023-01-05 16:59   ` Andrew Hlynskyi
2023-01-06  8:57     ` Jeff King
2023-01-06 12:40       ` Junio C Hamano
2023-01-06 13:04         ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).