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

Re: [PATCH v17 08/14] ref-filter: add support for %(contents:lines=X)

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 10, 2015, 17:14 UTC
Message-ID
<xmqqtwr242of.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1441900110-4015-9-git-send-email-Karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 9 quoted lines
> diff --git a/ref-filter.c b/ref-filter.c
> index 7d2732a..b098b16 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -56,6 +56,7 @@ static struct {
>  	{ "color" },
>  	{ "align" },
>  	{ "end" },
> +	{ "contents:lines" },

Do we even need "contents:lines" and existing other "contents:blah" in this list in the first place? If they are needed, group them together, not append at the end.

I wonder how this code sensibly can parse "%(contents:lines=6)". After splitting the format string at %( and closing ), the code calls parse_ref_filter_atom() and the rule that helper function uses to figure out the atom-name proper (which is to be checked against the valid_atom[] array) is to find the first colon, so

    %(contents:lines=6)

would cause "contents:lines=6" to be fed parse_ref_filter_atom(), it cheks if "contents" is in the valid_atom[] array (it is), and stores the whole thing in used_atom[].

So in that sense, match_atom_name() would do the right thing, but that would make any reader of this code realize that she never saw "contents:lines" entry in valid_atom[] array being used during this process.

Previous: Karthik NayakNext: Karthik Nayak
Message 26 of 56 in “port tag.c to use ref-filter APIs”
  1. 00/14 port tag.c to use ref-filter APIsKarthik Nayak, Sep 10, 2015
  2. 01/14 ref-filter: move `struct atom_value` to ref-filter.cKarthik Nayak, Sep 10, 2015
  3. 02/14 ref-filter: introduce ref_formatting_state and ref_formatting_stackKarthik Nayak, Sep 10, 2015
  4. 03/14 utf8: add function to align a string into given strbufKarthik Nayak, Sep 10, 2015
  5. 04/14 ref-filter: introduce handler function for each atomKarthik Nayak, Sep 10, 2015
  6. 05/14 ref-filter: introduce match_atom_name()Karthik Nayak, Sep 10, 2015
  7. Matthieu MoySep 10, 2015
  8. Junio C HamanoSep 10, 2015
  9. Matthieu MoySep 10, 2015
  10. Junio C HamanoSep 10, 2015
  11. Matthieu MoySep 10, 2015
  12. Junio C HamanoSep 10, 2015
  13. Karthik NayakSep 10, 2015
  14. Junio C HamanoSep 10, 2015
  15. Karthik NayakSep 10, 2015
  16. Junio C HamanoSep 10, 2015
  17. Karthik NayakSep 10, 2015
  18. 05/14 ref-filter: introduce match_atom_name()Karthik Nayak, Sep 11, 2015
  19. 06/14 ref-filter: implement an `align` atomKarthik Nayak, Sep 11, 2015
  20. 06/14 ref-filter: implement an `align` atomKarthik Nayak, Sep 10, 2015
  21. Matthieu MoySep 10, 2015
  22. Junio C HamanoSep 10, 2015
  23. 06/14 ref-filter: implement an `align` atomKarthik Nayak, Sep 11, 2015
  24. 07/14 ref-filter: add option to filter out tags, branches and remotesKarthik Nayak, Sep 10, 2015
  25. 08/14 ref-filter: add support for %(contents:lines=X)Karthik Nayak, Sep 10, 2015
  26. Junio C HamanoSep 10, 2015
  27. Karthik NayakSep 10, 2015
  28. 08/14 ref-filter: add support for %(contents:lines=X)Karthik Nayak, Sep 11, 2015
  29. 09/14 ref-filter: add support to sort by versionKarthik Nayak, Sep 10, 2015
  30. 10/14 ref-filter: add option to match literal patternKarthik Nayak, Sep 10, 2015
  31. 11/14 tag.c: use 'ref-filter' data structuresKarthik Nayak, Sep 10, 2015
  32. 12/14 tag.c: use 'ref-filter' APIsKarthik Nayak, Sep 10, 2015
  33. 12/14 tag.c: use 'ref-filter' APIsKarthik Nayak, Sep 11, 2015
  34. 13/14 tag.c: implement '--format' optionKarthik Nayak, Sep 10, 2015
  35. Junio C HamanoSep 10, 2015
  36. Karthik NayakSep 10, 2015
  37. 13/14 tag.c: implement '--format' optionKarthik Nayak, Sep 11, 2015
  38. 14/14 tag.c: implement '--merged' and '--no-merged' optionsKarthik Nayak, Sep 10, 2015
  39. John KeepingSep 17, 2015
  40. Junio C HamanoSep 17, 2015
  41. Matthieu MoySep 18, 2015
  42. John KeepingSep 18, 2015
  43. Matthieu MoySep 18, 2015
  44. Karthik NayakSep 18, 2015
  45. Matthieu MoySep 18, 2015
  46. Karthik NayakSep 18, 2015
  47. Matthieu MoySep 18, 2015
  48. Karthik NayakSep 18, 2015
  49. Matthieu MoySep 18, 2015
  50. Matthieu MoySep 10, 2015
  51. Karthik NayakSep 11, 2015
  52. Eric SunshineSep 11, 2015
  53. Junio C HamanoSep 11, 2015
  54. Karthik NayakSep 11, 2015
  55. Matthieu MoySep 12, 2015
  56. Karthik NayakSep 13, 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.