All of lore.kernel.org
 help / color / mirror / Atom feed
* GC can lose objects pointed to only by notes?
@ 2021-02-10 19:51 Martin von Zweigbergk
  2021-02-10 20:20 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Martin von Zweigbergk @ 2021-02-10 19:51 UTC (permalink / raw)
  To: git

From the "NOTES" section in `git help gc`:
"[...] it will keep [..] objects referenced by the index,
remote-tracking branches, notes saved by git notes under refs/notes/"

I had interpreted that as saying that it will keep objects pointed to
by notes saved under refs/notes. I had a repo with lots of commits
referred to only by notes. When I ran `git gc`, the commits they
pointed to were deleted (I had a backup, so no big deal). I now
understand that the documentation actually meant that "objects
referenced by the index and remote-tracking branches, as well as notes
saved by git notes under refs/notes/" are kept.

It seems that the documentation should at least be clarified. I had
read the documentation before I decided to rely on notes for keeping
my commits alive (which I now know was a mistake). I'll make sure to
add refs pointing directly to my commits instead now. I can send a
patch for the documentation unless someone else beats me to it (it's
been a while since my last patch for git, so it'll take some time for
me to get set up).

For a while, I also thought that `git gc` should be updated to also
keep objects with notes attached. However, as far as I understand, the
notes refs are never rewritten/rewound (only fast-forwarded), which
means that you would never be able to get rid of the old commits in
that case (just like you're already not able to get rid of old notes).
So I understand that you probably don't want to make that change.

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

* Re: GC can lose objects pointed to only by notes?
  2021-02-10 19:51 GC can lose objects pointed to only by notes? Martin von Zweigbergk
@ 2021-02-10 20:20 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2021-02-10 20:20 UTC (permalink / raw)
  To: Martin von Zweigbergk; +Cc: git

Martin von Zweigbergk <martinvonz@gmail.com> writes:

> From the "NOTES" section in `git help gc`:
> "[...] it will keep [..] objects referenced by the index,
> remote-tracking branches, notes saved by git notes under refs/notes/"
>
> I had interpreted that as saying that it will keep objects pointed to
> by notes saved under refs/notes.

The documentation needs updating.

There is no reachability from the notes that point at an otherwise
uninteresting objects that are not pointed at by real refs, so a
note that talks about a commit that is pruned will become stale.

It is the reason why we need the "git notes prune" subcommand.

Thanks.

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

end of thread, other threads:[~2021-02-10 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 19:51 GC can lose objects pointed to only by notes? Martin von Zweigbergk
2021-02-10 20:20 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.