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

Re: [PATCH v3 3/9] ref-filter: support printing N lines from tag annotation

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 20, 2015, 00:02 UTC
Message-ID
<CAPig+cSXuJ7ohR=afzRbmfLtEuzhGYYTznc2J_qxwgBKwyYu9Q@mail.gmail.com>
In-Reply-To
<1437246749-14423-4-git-send-email-Karthik.188@gmail.com>
On Sat, Jul 18, 2015 at 3:12 PM, Karthik Nayak <karthik.188@gmail.com> wrote:
Show 17 quoted lines
> In 'tag.c' we can print N lines from the annotation of the tag using
> the '-n<num>' option. Copy code from 'tag.c' to 'ref-filter' and
> modify 'ref-filter' to support printing of N lines from the annotation
> of tags.
>
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
> diff --git a/ref-filter.c b/ref-filter.c
> index 771c48d..82731ac 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -1288,7 +1288,48 @@ static void assign_formating(struct ref_array_item *ref, int parsed_atom, struct
>         }
>  }
>
> -void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style)
> +/* Print 'lines' no of lines of a given oid */

This is difficult to read and understand. I presume you meant "no." as shorthand for "number" but dropped the period. Even with the period, it's still hard to read. Perhaps rewrite it as:

    If 'lines' is greater than 0, print that may lines of...
or something.
Show 14 quoted lines
> diff --git a/ref-filter.h b/ref-filter.h
> index c18781b..7dfdea0 100644
> --- a/ref-filter.h
> +++ b/ref-filter.h
> @@ -87,8 +88,11 @@ int parse_ref_filter_atom(const char *atom, const char *ep);
>  int verify_ref_format(const char *format);
>  /*  Sort the given ref_array as per the ref_sorting provided */
>  void ref_array_sort(struct ref_sorting *sort, struct ref_array *array);
> -/*  Print the ref using the given format and quote_style */
> -void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style);
> +/*
> + * Print the ref using the given format and quote_style. If lines > 0,
> + * prints the "lines" no of lines of the objected pointed to.
> + */
Same problem. This literal "no" is quite confusing. Perhaps rewrite as above:
    If lines > 0, print that many lines of...
> +void show_ref_array_item(struct ref_array_item *info, const char *format, int quote_style, unsigned int lines);

ref-filter.h seems to be setting a precedent for overlong lines. Wrapping this manually could improve readability.

Show 5 quoted lines
>  /*  Callback function for parsing the sort option */
>  int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset);
>  /*  Default sort option based on refname */
> --
> 2.4.6
Previous: Karthik NayakNext: Karthik Nayak
Message 18 of 37 in “Port tag.c to use ref-filter APIs”
  1. 0/9 Port tag.c to use ref-filter APIsKarthik Nayak, Jul 18, 2015
  2. 1/9 ref-filter: add option to align atoms to the leftKarthik Nayak, Jul 18, 2015
  3. Eric SunshineJul 19, 2015
  4. Karthik NayakJul 20, 2015
  5. Junio C HamanoJul 20, 2015
  6. Eric SunshineJul 20, 2015
  7. Junio C HamanoJul 20, 2015
  8. Karthik NayakJul 20, 2015
  9. 1/9 ref-filter: add option to align atoms to the leftKarthik Nayak, Jul 20, 2015
  10. Eric SunshineJul 20, 2015
  11. Karthik NayakJul 20, 2015
  12. Junio C HamanoJul 20, 2015
  13. Karthik NayakJul 21, 2015
  14. Matthieu MoyJul 22, 2015
  15. Karthik NayakJul 23, 2015
  16. 2/9 ref-filter: add option to filter only tagsKarthik Nayak, Jul 18, 2015
  17. 3/9 ref-filter: support printing N lines from tag annotationKarthik Nayak, Jul 18, 2015
  18. Eric SunshineJul 20, 2015
  19. Karthik NayakJul 20, 2015
  20. 4/9 ref-filter: add support to sort by versionKarthik Nayak, Jul 18, 2015
  21. Eric SunshineJul 20, 2015
  22. Karthik NayakJul 20, 2015
  23. 5/9 ref-filter: add option to match literal patternKarthik Nayak, Jul 18, 2015
  24. Eric SunshineJul 20, 2015
  25. Christian CouderJul 20, 2015
  26. Eric SunshineJul 20, 2015
  27. Karthik NayakJul 21, 2015
  28. Matthieu MoyJul 22, 2015
  29. 6/9 tag.c: use 'ref-filter' data structuresKarthik Nayak, Jul 18, 2015
  30. 7/9 tag.c: use 'ref-filter' APIsKarthik Nayak, Jul 18, 2015
  31. 8/9 tag.c: implement '--format' optionKarthik Nayak, Jul 18, 2015
  32. Matthieu MoyJul 22, 2015
  33. 9/9 tag.c: implement '--merged' and '--no-merged' optionsKarthik Nayak, Jul 18, 2015
  34. Christian CouderJul 19, 2015
  35. Karthik NayakJul 21, 2015
  36. Matthieu MoyJul 22, 2015
  37. Karthik NayakJul 23, 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.