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

Re: [PATCH 1/5] ref-filter: support different email formats

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Jul 28, 2020, 13:58 UTC
Message-ID
<20200728135803.GD24134@danh.dev>
In-Reply-To
<aeb116c5aaaa23dfefbc7a6f4ac743a6f5a3ade8.1595882588.git.gitgitgadget@gmail.com>
[this is a resent, my previous mail couldn't reach the archive]
On 2020-07-27 20:43:04+0000, Hariom Verma via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 48 quoted lines
> From: Hariom Verma <hariom18599@gmail.com>
> 
> Currently, ref-filter only supports printing email with arrow brackets.
> 
> Let's add support for two more email options.
> - trim : print email without arrow brackets.
> - localpart : prints the part before the @ sign
> 
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Mentored-by: Heba Waly <heba.waly@gmail.com>
> Signed-off-by: Hariom Verma <hariom18599@gmail.com>
> ---
>  ref-filter.c            | 36 ++++++++++++++++++++++++++++++++----
>  t/t6300-for-each-ref.sh | 16 ++++++++++++++++
>  2 files changed, 48 insertions(+), 4 deletions(-)
> 
> diff --git a/ref-filter.c b/ref-filter.c
> index 8447cb09be..8563088eb1 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -102,6 +102,10 @@ static struct ref_to_worktree_map {
>  	struct worktree **worktrees;
>  } ref_to_worktree_map;
>  
> +static struct email_option{
> +	enum { EO_INVALID, EO_RAW, EO_TRIM, EO_LOCALPART } option;
> +} email_option;
> +
>  /*
>   * An atom is a valid field atom listed below, possibly prefixed with
>   * a "*" to denote deref_tag().
> @@ -1040,10 +1044,26 @@ static const char *copy_email(const char *buf)
>  	const char *eoemail;
>  	if (!email)
>  		return xstrdup("");
> -	eoemail = strchr(email, '>');
> +	switch (email_option.option) {
> +	case EO_RAW:
> +		eoemail = strchr(email, '>') + 1;
> +		break;
> +	case EO_TRIM:
> +		email++;
> +		eoemail = strchr(email, '>');
> +		break;
> +	case EO_LOCALPART:
> +		email++;
> +		eoemail = strchr(email, '@');
> +		break;

This is not correct. RFC-822 allows @ in local part, albeit, that localpart must be quoted:

        addr-spec       =       local-part "@" domain
        local-part      =       dot-atom / quoted-string / obs-local-part
        quoted-string   =       [CFWS]
                                DQUOTE *([FWS] qcontent) [FWS] DQUOTE
                                [CFWS]
        qcontent        =       qtext / quoted-pair
        qtext           =       NO-WS-CTL /     ; Non white space
        qtext           =       NO-WS-CTL /     ; Non white space controls
                                %d33 /          ; The rest of the US-ASCII
                                %d35-91 /       ;  characters not including "\"
                                %d93-126        ;  or the quote character
        quoted-pair     =       ("\" text) / obs-qp

IOW, those below email addresses are valid email address, and the local part is `quoted@local'

        "quoted@local"@example.com
        quoted\@local@example.com

Anyway, it seems like current Git strips first `"' from `"quoted@local"@example.com'

-- 
Danh
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 51 in “[GSoC] Improvements to ref-filter”
  1. 0/5 [GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Jul 27, 2020
  2. 1/5 ref-filter: support different email formatsHariom Verma via GitGitGadget, Jul 27, 2020
  3. Junio C HamanoJul 27, 2020
  4. Hariom vermaJul 28, 2020
  5. Junio C HamanoJul 28, 2020
  6. Đoàn Trần Công DanhJul 28, 2020
  7. Junio C HamanoJul 28, 2020
  8. 2/5 ref-filter: add `short` option for 'tree' and 'parent'Hariom Verma via GitGitGadget, Jul 27, 2020
  9. Junio C HamanoJul 27, 2020
  10. 3/5 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Jul 27, 2020
  11. 4/5 format-support: move `format_sanitized_subject()` from prettyHariom Verma via GitGitGadget, Jul 27, 2020
  12. 5/5 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Jul 27, 2020
  13. 0/9 [GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Aug 5, 2020
  14. 1/9 ref-filter: support different email formatsHariom Verma via GitGitGadget, Aug 5, 2020
  15. 2/9 ref-filter: refactor `grab_objectname()`Hariom Verma via GitGitGadget, Aug 5, 2020
  16. 3/9 ref-filter: modify error messages in `grab_objectname()`Hariom Verma via GitGitGadget, Aug 5, 2020
  17. 4/9 ref-filter: rename `objectname` related functions and fieldsHariom Verma via GitGitGadget, Aug 5, 2020
  18. 5/9 ref-filter: add `short` modifier to 'tree' atomHariom Verma via GitGitGadget, Aug 5, 2020
  19. 6/9 ref-filter: add `short` modifier to 'parent' atomHariom Verma via GitGitGadget, Aug 5, 2020
  20. 8/9 format-support: move `format_sanitized_subject()` from prettyHariom Verma via GitGitGadget, Aug 5, 2020
  21. 9/9 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Aug 5, 2020
  22. 7/9 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Aug 5, 2020
  23. Junio C HamanoAug 5, 2020
  24. Hariom vermaAug 6, 2020
  25. 0/9 [Resend][GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Aug 17, 2020
  26. 2/9 ref-filter: refactor `grab_objectname()`Hariom Verma via GitGitGadget, Aug 17, 2020
  27. 3/9 ref-filter: modify error messages in `grab_objectname()`Hariom Verma via GitGitGadget, Aug 17, 2020
  28. 1/9 ref-filter: support different email formatsHariom Verma via GitGitGadget, Aug 17, 2020
  29. 4/9 ref-filter: rename `objectname` related functions and fieldsHariom Verma via GitGitGadget, Aug 17, 2020
  30. 7/9 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Aug 17, 2020
  31. Junio C HamanoAug 17, 2020
  32. Hariom vermaAug 19, 2020
  33. Junio C HamanoAug 19, 2020
  34. Junio C HamanoAug 19, 2020
  35. Hariom vermaAug 20, 2020
  36. Hariom vermaAug 20, 2020
  37. 6/9 ref-filter: add `short` modifier to 'parent' atomHariom Verma via GitGitGadget, Aug 17, 2020
  38. 5/9 ref-filter: add `short` modifier to 'tree' atomHariom Verma via GitGitGadget, Aug 17, 2020
  39. 8/9 format-support: move `format_sanitized_subject()` from prettyHariom Verma via GitGitGadget, Aug 17, 2020
  40. Junio C HamanoAug 17, 2020
  41. 9/9 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Aug 17, 2020
  42. Junio C HamanoAug 17, 2020
  43. 0/8 [GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Aug 21, 2020
  44. 1/8 ref-filter: support different email formatsHariom Verma via GitGitGadget, Aug 21, 2020
  45. 2/8 ref-filter: refactor `grab_objectname()`Hariom Verma via GitGitGadget, Aug 21, 2020
  46. 3/8 ref-filter: modify error messages in `grab_objectname()`Hariom Verma via GitGitGadget, Aug 21, 2020
  47. 5/8 ref-filter: add `short` modifier to 'tree' atomHariom Verma via GitGitGadget, Aug 21, 2020
  48. 6/8 ref-filter: add `short` modifier to 'parent' atomHariom Verma via GitGitGadget, Aug 21, 2020
  49. 8/8 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Aug 21, 2020
  50. 4/8 ref-filter: rename `objectname` related functions and fieldsHariom Verma via GitGitGadget, Aug 21, 2020
  51. 7/8 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Aug 21, 2020

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.