{"thread":{"id":"55133","subject":"GC can lose objects pointed to only by notes?","startedAt":"2021-02-10T19:52:24Z","lastAt":"2021-02-10T20:23:19Z","messageCount":2,"participants":["Martin von Zweigbergk","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"416651","messageId":"CANiSa6h=S6tHUR4hY85uZ7ZcnDc2mdUzPwyBDakQAa_NP+O0YA@mail.gmail.com","threadId":"55133","inReplyTo":null,"subject":"GC can lose objects pointed to only by notes?","fromName":"Martin von Zweigbergk","fromEmail":"martinvonz@gmail.com","sentAt":"2021-02-10T19:51:16Z","receivedAt":"2021-02-10T19:52:24Z","isPatch":false,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"From the \"NOTES\" section in `git help gc`:\n\"[...] it will keep [..] objects referenced by the index,\nremote-tracking branches, notes saved by git notes under refs/notes/\"\n\nI had interpreted that as saying that it will keep objects pointed to\nby notes saved under refs/notes. I had a repo with lots of commits\nreferred to only by notes. When I ran `git gc`, the commits they\npointed to were deleted (I had a backup, so no big deal). I now\nunderstand that the documentation actually meant that \"objects\nreferenced by the index and remote-tracking branches, as well as notes\nsaved by git notes under refs/notes/\" are kept.\n\nIt seems that the documentation should at least be clarified. I had\nread the documentation before I decided to rely on notes for keeping\nmy commits alive (which I now know was a mistake). I'll make sure to\nadd refs pointing directly to my commits instead now. I can send a\npatch for the documentation unless someone else beats me to it (it's\nbeen a while since my last patch for git, so it'll take some time for\nme to get set up).\n\nFor a while, I also thought that `git gc` should be updated to also\nkeep objects with notes attached. However, as far as I understand, the\nnotes refs are never rewritten/rewound (only fast-forwarded), which\nmeans that you would never be able to get rid of the old commits in\nthat case (just like you're already not able to get rid of old notes).\nSo I understand that you probably don't want to make that change.\n"},{"id":"416655","messageId":"xmqq35y33c9u.fsf@gitster.c.googlers.com","threadId":"55133","inReplyTo":"CANiSa6h=S6tHUR4hY85uZ7ZcnDc2mdUzPwyBDakQAa_NP+O0YA@mail.gmail.com","subject":"Re: GC can lose objects pointed to only by notes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-10T20:20:45Z","receivedAt":"2021-02-10T20:23:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin von Zweigbergk <martinvonz@gmail.com> writes:\n\n> From the \"NOTES\" section in `git help gc`:\n> \"[...] it will keep [..] objects referenced by the index,\n> remote-tracking branches, notes saved by git notes under refs/notes/\"\n>\n> I had interpreted that as saying that it will keep objects pointed to\n> by notes saved under refs/notes.\n\nThe documentation needs updating.\n\nThere is no reachability from the notes that point at an otherwise\nuninteresting objects that are not pointed at by real refs, so a\nnote that talks about a commit that is pruned will become stale.\n\nIt is the reason why we need the \"git notes prune\" subcommand.\n\nThanks.\n"}]}