git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] notes: allow merging from arbitrary references

From
Jacob Keller <jacob.keller@gmail.com>
Date
Nov 18, 2015, 22:38 UTC
Message-ID
<CA+P7+xoDi54ZQFJp7eK5p7QqtWHqpsjLNO5oo_Q5kpuwOXVbww@mail.gmail.com>
In-Reply-To
<CALKQrge+agZ2NstnjkkVKmgqQRtE1cwiq6d7B9bP4_VApq+e_Q@mail.gmail.com>
On Wed, Nov 18, 2015 at 2:29 PM, Johan Herland <johan@herland.net> wrote:
Show 14 quoted lines
> On Mon, Nov 16, 2015 at 8:41 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
>> The main other issue is how to get notes DWIM things to work for all
>> cases where we want to use notes refs, since right now the DWIM is
>> basically done at the top level and only handles notes like things.
>> The problem with it is that if you specify a full ref that *isn't*
>> refs/notes, you will always prefix it with refs/notes, like so:
>>
>> refs/remote-notes/origin => refs/notes/refs/remote-notes/origin,
>
> I am becoming convinced that this is a bug. I don't know anywhere else
> in Git, where a fully qualified ref name (i.e. anything starting with
> "refs/") is not interpreted verbatim. For the notes code to do just
> that adds unnecessary confusion.
>

I agree, and I had a patch to change this behavior, but the main issue being I think it didn't fallback to the suggested proposal below.

Show 13 quoted lines
>> This makes it really difficult to expand a ref. However, Junio seemed
>> to think this was a possibly valuable expansion under normal
>> circumstances.
>
> I doubt it. It carries its own set of problems in that refs/foo/bar
> (=> refs/notes/refs/foo/bar) is treated differently from refs/notes/bar
> (=> refs/notes/bar). If users _really_ want to create
> refs/notes/refs/$whatever, they should have to be explicit about that
> (i.e. we should require them to say refs/notes/refs/$whatever instead
> of allowing them to lazily say refs/$whatever). (It even saves them
> from a potential bug if their $whatever happens to start with "notes/",
> in which case the current code already forces them to fully qualify...)
>
The question is whether we do:
a) check for refs/abc/xyz and fail if we can't find it or

b) check for refs/abc/xyz and then expand to refs/notes/refs/abc/xyz if we can't?

I think that the first is generally preferable but with read-only ops it's not a big deal since we won't be writing to notes trees.

Show 49 quoted lines
> I realize this is a backwards-incompatible change in behavior, but I
> don't think it'll matter much in practice. Given e.g.
>
>   git notes --ref refs/foo list
>
> when refs/foo and refs/notes/refs/foo is both missing:
>   Current behavior: refs/notes/refs/foo lookup fails.
>     Treat like empty notes tree; no output, exit code 0
>   Proposed behavior: refs/foo lookup fails -> refs/notes/refs/foo
>     lookup fails. Same behavior as current.
>
> when refs/notes/refs/foo exists:
>   Current behavior: refs/notes/refs/foo lookup succeeds.
>     Shows notes in that tree
>   Proposed behavior: refs/foo lookup fails -> refs/notes/refs/foo
>     lookup succeeds. Same as current.
>
> when refs/foo exists:
>   Current behavior: refs/notes/refs/foo lookup fails. Treat like empty
>     notes tree; no output, exit code 0
>   Proposed behavior: refs/foo lookup succeeds. Load as notes tree,
>     probably empty, hence no output, exit code 0
>
> when both refs/foo and refs/notes/refs/foo exist:
>   Current behavior: refs/notes/refs/foo lookup succeeds. Shows notes
>     in that tree
>   Proposed behavior: refs/foo lookup succeeds. Load as notes tree,
>     probably empty, hence no output, exit code 0
>
> In other words, this change requires both refs/foo and
> refs/notes/refs/foo to be present in order to cause any real confusion.
> And in that case, the proposed behavior forces you to use fully-
> qualified refs (which will be interpreted as such) whereas the current
> behavior takes what looks like a fully-qualified ref (refs/foo) and
> interprets it like a notes-shorthand (-> refs/notes/refs/foo), which
> I argue is probably more confusing to most users.
>
>> The current solution is to try to do a normal lookup
>> first and only use the notes DWIM after we fail a lookup, which I
>> think is what the above patch attempts to do. This seems ok enough to
>> me.
>
> Yes, given $whatever, we should first lookup $whatever, and only
> failing that, we should try refs/notes/$whatever. Maybe it's also
> worth trying refs/$whatever (before refs/notes/$whatever), since that
> would be consistent with what's currently done for other refs (e.g.
> try "git log heads/master" or "git log tags/v2.6.3" in git.git).
>
>

The biggest implementation issue here is that the notes code that does DWIM happens before lookup of whether the ref exists, and the code that does lookup of refs in the notes.c code won't fallback and try a different expansion.

I think that is why my proposed change was dropped, if I remember correctly.

I am in agreement with you, and think we should use the proposed behavior above, as it is very unlikely to cause any issues with current cases, especially since we already try not to allow operation on refs outside of the notes tree today.

Regards, Jake

Show 5 quoted lines
> ...Johan
>
> --
> Johan Herland, <johan@herland.net>
> www.herland.net
Previous: Johan HerlandNext: Jeff King
Message 7 of 12 in “notes: allow merging from arbitrary references”
  1. notes: allow merging from arbitrary referencesJacob Keller, Nov 13, 2015
  2. Johan HerlandNov 15, 2015
  3. Jacob KellerNov 15, 2015
  4. Johan HerlandNov 16, 2015
  5. Jacob KellerNov 16, 2015
  6. Johan HerlandNov 18, 2015
  7. Jacob KellerNov 18, 2015
  8. Jeff KingNov 24, 2015
  9. Jeff KingNov 24, 2015
  10. Jacob KellerNov 26, 2015
  11. Junio C HamanoDec 11, 2015
  12. Jacob KellerDec 11, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.