git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [QUESTION] ref-filter: how to support atom like %an
@ 2021-05-15 14:52 ZheNing Hu
  2021-05-16  3:55 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: ZheNing Hu @ 2021-05-15 14:52 UTC (permalink / raw)
  To: Git List, Junio C Hamano, Jeff King, Hariom verma, Christian Couder

My current thinking is this:

First add a new member `short_name` in `struct valid_atom`,
Then we can share a valid_atom item for the long name of
an atom such as `%(authoremail)` and the short name of
the atom `%ae` (%aE is not considered at the time).
Something like:

[ATOM_AUTHOREMAIL] = { "ae", "authoremail", SOURCE_OBJ, FIELD_STR,
person_email_atom_parser },

Then we need to do some work on atoms parsing:
In the original design of `parse_ref_filter_atom()`, it relied on
searching for `%(` and `)` to find an atom. Now we have to
change the way of finding atoms: Currently I just replace
`find_next()` to find a single `%`. If there is `(` after `%`,
we can keep the original long name atoms parsing method,
otherwise we are dealing with the short name atom,
we need to pass the interval between the current `%`
and the next single `%` to `parse_ref_filter_atom()`.
Then we are in `parse_ref_filter_atom()`, we need to
consider these situations:

1. %(authoremail:trim)
2. %(authoremail)
3. %ae
4. %ae:trim
5. %aeabc:trim
6. %ae:trimabcd...

As we can see, the situation is starting to get complicated.
The more critical point is as in case 6: We cannot determine
the end of a short name atom because it does not have an
explicit `)` end.
In this way, many of the `*_atom_parser` functions in
`ref-filter.c` will not work, because most of them use `strcmp()`
to check the attribute of an atom. If we want to support the
short name `%ae`, that would require a large-scale rewrite.

Any good ideas, friends?

--
ZheNing Hu

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

* Re: [QUESTION] ref-filter: how to support atom like %an
  2021-05-15 14:52 [QUESTION] ref-filter: how to support atom like %an ZheNing Hu
@ 2021-05-16  3:55 ` Junio C Hamano
  2021-05-17  2:13   ` ZheNing Hu
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2021-05-16  3:55 UTC (permalink / raw)
  To: ZheNing Hu; +Cc: Git List, Jeff King, Hariom verma, Christian Couder

ZheNing Hu <adlternative@gmail.com> writes:

> My current thinking is this:
>
> First add a new member `short_name` in `struct valid_atom`,
> Then we can share a valid_atom item for the long name of
> an atom such as `%(authoremail)` and the short name of
> the atom `%ae` (%aE is not considered at the time).
> Something like:
>
> [ATOM_AUTHOREMAIL] = { "ae", "authoremail", SOURCE_OBJ, FIELD_STR,
> person_email_atom_parser },

My assumption has always been that when enriching "--format" of the
"log" family (e.g. "status", "show") with ingredients from the
"for-each-ref" family (e.g. "branch", "tag"), we would adopt the
notation the latter uses, i.e. "git log --format='%s %(notes)'",
with the full intention that eventually users would choose between
the synonyms to make it "git log --format='%(subject) %(notes)'" for
consistency, without wasting brain cycles to come up with and to
remember two-letter shorthands that will not scale.


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

* Re: [QUESTION] ref-filter: how to support atom like %an
  2021-05-16  3:55 ` Junio C Hamano
@ 2021-05-17  2:13   ` ZheNing Hu
  0 siblings, 0 replies; 3+ messages in thread
From: ZheNing Hu @ 2021-05-17  2:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, Jeff King, Hariom verma, Christian Couder

Junio C Hamano <gitster@pobox.com> 于2021年5月16日周日 上午11:55写道:
>
> ZheNing Hu <adlternative@gmail.com> writes:
>
> > My current thinking is this:
> >
> > First add a new member `short_name` in `struct valid_atom`,
> > Then we can share a valid_atom item for the long name of
> > an atom such as `%(authoremail)` and the short name of
> > the atom `%ae` (%aE is not considered at the time).
> > Something like:
> >
> > [ATOM_AUTHOREMAIL] = { "ae", "authoremail", SOURCE_OBJ, FIELD_STR,
> > person_email_atom_parser },
>
> My assumption has always been that when enriching "--format" of the
> "log" family (e.g. "status", "show") with ingredients from the
> "for-each-ref" family (e.g. "branch", "tag"), we would adopt the
> notation the latter uses, i.e. "git log --format='%s %(notes)'",
> with the full intention that eventually users would choose between
> the synonyms to make it "git log --format='%(subject) %(notes)'" for
> consistency, without wasting brain cycles to come up with and to
> remember two-letter shorthands that will not scale.
>

Well, it’s truly more useful to provide long name atoms for the "log" family,
But if we need to establish a unified interface for --format, shouldn't
we extend it base on `ref-filter`?

At present, the scalability of the implementation in `ref-filter` is better,
but it does not support two-letter shorthands atoms...

--
ZheNing Hu

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

end of thread, other threads:[~2021-05-17  2:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 14:52 [QUESTION] ref-filter: how to support atom like %an ZheNing Hu
2021-05-16  3:55 ` Junio C Hamano
2021-05-17  2:13   ` ZheNing Hu

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git