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

Re: [PATCH] [GSOC] ref-filter: add %(notes) format atom

From
Junio C Hamano <gitster@pobox.com>
Date
May 3, 2021, 02:56 UTC
Message-ID
<xmqqsg34a5j8.fsf@gitster.g>
In-Reply-To
<CAOLTT8TGaVxxHJRF_-Dq0Gnd50_H-80C6zPhjQAQruiO59qw2A@mail.gmail.com>
ZheNing Hu <adlternative@gmail.com> writes:
Show 5 quoted lines
> Note that `cat-file --batch` should be a superset of `ref-filter` and
> `--pretty`, because
> it supports all objects, while `ref-filter` only supports "commit" and
> "tag" two kinds
> of objects, and `--pretty` only supports "commit" one kind of object.

What? A ref can point at any kind of objects, not necessarily commits and tags. %(objectname), %(objecttype), etc. obviously are applicable to any type of object.

Another thing worth noting is that ref-filter needs to deal with traits that are not tied to any particular object, but to the ref itself, like who its upstream is and where it would be pushed to.

> So it may be reasonable to provide `%(notes)` to "commit","tag"
> objects in `cat-file --batch`
> in the future, now integrate them into ref-filter firstly.

And you can attach notes to objects of any type, not limited to commits and tags.

>> >     So in this patch, I tried to migrate --pretty=%N to --format=%(notes).
What do you mean by "migrate"?  Are you making both available?
Show 10 quoted lines
>> > diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
>> > index 2ae2478de706..07f037a16e13 100644
>> > --- a/Documentation/git-for-each-ref.txt
>> > +++ b/Documentation/git-for-each-ref.txt
>> > @@ -139,6 +139,9 @@ deltabase::
>> >       given object, if it is stored as a delta.  Otherwise it
>> >       expands to the null object name (all zeroes).
>> >
>> > +notes::
>> > +     The notes associated with the ref.
"The notes associated with the object pointed at by the ref".

A note is never associated with a ref. It can only associated with an object.

If we are going to have %(notes), it may be natural to desire grabbing notes for the given object from specified notes ref, e.g.

    git for-each-ref --format="%(notes:amlog) %(subject)" zh/pretty-date-human
may want to give the same kind of information as
    git show -s --format='%N %s' --notes=amlog zh/pretty-date-human

The underlying notes machinery however may not be prepared to work with more than one notes tree at the same time, so

    git for-each-ref --format="%(notes) %(subject)" --notes=amlog zh/pretty-date-human

might be a better syntax, as --format="%(notes:X) %(notes:Y)" may not be something you can easily support.

Previous: ZheNing HuNext: ZheNing Hu
Message 4 of 5 in “[GSOC] ref-filter: add %(notes) format atom”
  1. [GSOC] ref-filter: add %(notes) format atomZheNing Hu via GitGitGadget, Apr 29, 2021
  2. René ScharfeMay 1, 2021
  3. ZheNing HuMay 2, 2021
  4. Junio C HamanoMay 3, 2021
  5. ZheNing HuMay 3, 2021

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.