Re: [PATCH 07/18] builtin/notes.c: Split notes ref DWIMmery into a separate function
- From
Johan Herland <johan@herland.net>
- Date
- Oct 7, 2010, 13:56 UTC
- Message-ID
- <201010071556.14555.johan@herland.net>
- In-Reply-To
- <20101005155053.GH12797@burratino>
On Tuesday 5. October 2010 17.50.53 Jonathan Nieder wrote:
Show 12 quoted lines
> Johan Herland wrote:
> > +static void expand_notes_ref(struct strbuf *sb)
> > +{
> > + if (!prefixcmp(sb->buf, "refs/notes/"))
> > + return; /* we're happy */
> > + else if (!prefixcmp(sb->buf, "notes/"))
> > + strbuf_insert(sb, 0, "refs/", 5);
> > + else
> > + strbuf_insert(sb, 0, "refs/notes/", 11);
> > +}
>
> Aside: I'm not sure this is the most convenient rule to use after all.FTR, that rule is not introduced by this patch, the patch merely moves it into a separate function.
Show 25 quoted lines
> Example: > > $ git log --notes-ref=charon/notes/full > fatal: unrecognized argument: --notes-ref=charon/notes/full > $ git log --show-notes=charon/notes/full > warning: notes ref refs/notes/charon/notes/full is invalid > ... > $ git log --show-notes=remotes/charon/notes/full > warning: notes ref refs/notes/remotes/charon/notes/full is invalid > ... > $ git log --show-notes=refs/remotes/charon/notes/full -1 > commit 16461e8e5fc5b2dbe9176b9a8313c395e1e07304 > Merge: c3e5a06 79bd09f > Author: Junio C Hamano <gitster@pobox.com> > Date: Thu Sep 30 16:02:27 2010 -0700 > > Merge branch 'il/remote-fd-ext' into pu > > * il/remote-fd-ext: > fixup! git-remote-fd > > Notes (remotes/charon/notes/full): > Pu-Overview: > What's cooking in git.git (Sep 2010, #07; Wed, 29) > $
Indeed, if you keep notes refs outside refs/notes, the current behaviour is not very user-friendly. So far, we've required all notes refs to be within refs/notes. (See for example init_notes_check() in builtin/notes.c, which refuses to work with notes refs outside 'refs/notes/', hence was probably the reason for adding the above code in the first place.)
I guess this moves us towards the discussion of how to handle remote notes refs and how to synchronize them on fetch/push. In short, if we want to keep notes refs outside of refs/notes (e.g. in refs/remotes/foo/notes), we need to change this part of the code.
> And now that I think of it, the revision args parser uses its own code > for this...
I assuming you're talking about the revision args parser's DWIMing of "foo" into the first existing ref in the following list:
1. $GIT_DIR/foo 2. refs/foo 3. refs/tags/foo 4. refs/heads/foo 5. refs/remotes/foo 6. refs/remotes/foo/HEAD
If we want to reuse this DWIMery, we obviously want a different list of "auto- completions". Maybe something like:
1. refs/notes/foo 2. refs/remote-notes/foo (depends on how we organize remote notes refs) 3. ?
> Regardless, this patch is a step in the right direction imho.
Thanks, I expect future patches to change this code in order to deal with remote notes refs. For the purposes of the current patch series, I will assume that all notes refs live under refs/notes.
...Johan
-- Johan Herland, <johan@herland.net> www.herland.net