Subject: Re: [RFC PATCH 1/2] notes: support fetching notes from an external repo

From: Junio C Hamano <[email-masked]>
Date: Tue, 02 Aug 2022 08:40:19 -0700

Vegard Nossum <[email-masked]> writes:

> Notes are currently always fetched from the current repo. However, in
> certain situations you may want to keep notes in a separate repository
> altogether.
>
> In my specific case, I am using cgit to display notes for repositories
> that are owned by others but hosted on a shared machine, so I cannot
> really add the notes directly to their repositories.

My gut reaction is that I am not interested at all in the above
approach, even though the problem you are trying to solve is
interesting.  Mostly because notes are not the only decorations your
users may want.  What if you want to "log --decorate" their
repository contents with your own tags that annotate their commits?
A notes-only approach to mix repositories is way too narrow.

A usable alternative _might_ be to introduce a way to "borrow" refs
and objects from a different repository as if you cloned from and
continuously fetching from them.  We already have a mechanism to
borrow objects from another repository in the form of "alternate
object database" that lets us pretend objects in their repository
are locally available.  We can invent a similar mechanism that lets
any of their ref as if it were our local ref, e.g. their "main"
branch at their refs/heads/main might appear to exist at our
refs/borrowed/X/heads/main.  

Once the mechanism for doing so is in place, setting up such a
parasite repository might be

    $ git clone --local-parasite=X /path/to/theirs mine

which would create an empty repository 'mine' that uses
/path/to/theirs/.git/objects as one of its alternate object store,
and their refs are borrowed under our refs/borrowed/X/.

Then you can tell your cgit to show refs/borrowed/X/{heads,tags}
hierarchies as if they are the branches and tags, and use your own
refs/notes/ hiearchy to store whatever notes they do not let you
store in theirs.