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

Re: [PATCH v2 2/5] ref-filter: add function to print single ref_array_item

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2016, 17:35 UTC
Message-ID
<xmqqfuolp7nk.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160926224233.32702-3-santiago@nyu.edu>
santiago@nyu.edu writes:
Show 35 quoted lines
> From: Lukas P <luk.puehringer@gmail.com>
>
> ref-filter functions are useful for printing git object information
> using a format specifier. However, some other modules may not want to use
> this functionality on a ref-array but only print a single item.
>
> Expose a format_ref function to create, pretty print and free individual
> ref-items.
>
> Signed-off-by: Lukas P <luk.puehringer@gmail.com>
> ---
> +void format_ref(const char *name, const unsigned char *sha1, const char *format,
> +		unsigned kind)
> +{
> +	struct ref_array_item *ref_item;
> +	ref_item = new_ref_array_item(name, sha1, 0);
> +	ref_item->kind = kind;
> +	show_ref_array_item(ref_item, format, 0);
> +	free_array_item(ref_item);
> +}
> +
>  /*  If no sorting option is given, use refname to sort as default */
>  struct ref_sorting *ref_default_sorting(void)
>  {
> diff --git a/ref-filter.h b/ref-filter.h
> index 14d435e..1ef7999 100644
> --- a/ref-filter.h
> +++ b/ref-filter.h
> @@ -107,4 +107,8 @@ struct ref_sorting *ref_default_sorting(void);
>  /*  Function to parse --merged and --no-merged options */
>  int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset);
>  
> +/* Pretty-print a single ref */
> +void format_ref(const char *name, const unsigned char *sha1, const char *format,
> +		unsigned kind);

The fact that you felt a need for comment before its name is a strong sign that the name is not sufficiently descriptive and understandable for readers to tell what the function is for.

Would pretty_print_ref() or show_ref_pretty() better names, perhaps?
Previous: santiago@nyu.eduNext: santiago@nyu.edu
Message 10 of 17 in “Add --format to tag verification”
  1. 0/5 Add --format to tag verificationsantiago@nyu.edu, Sep 26, 2016
  2. 1/5 gpg-interface, tag: add GPG_VERIFY_QUIET flagsantiago@nyu.edu, Sep 26, 2016
  3. Junio C HamanoSep 27, 2016
  4. Lukas PühringerSep 27, 2016
  5. Junio C HamanoSep 27, 2016
  6. Lukas PühringerSep 27, 2016
  7. Stefan BellerSep 27, 2016
  8. Lukas PühringerSep 27, 2016
  9. 2/5 ref-filter: add function to print single ref_array_itemsantiago@nyu.edu, Sep 26, 2016
  10. Junio C HamanoSep 27, 2016
  11. 3/5 tag: add format specifier to gpg_verify_tagsantiago@nyu.edu, Sep 26, 2016
  12. 5/5 builtin/tag: add --format argument for tag -vsantiago@nyu.edu, Sep 26, 2016
  13. Junio C HamanoSep 27, 2016
  14. 4/5 builtin/verify-tag: add --format to verify-tagsantiago@nyu.edu, Sep 26, 2016
  15. Philip OakleySep 27, 2016
  16. Santiago TorresSep 27, 2016
  17. Junio C HamanoSep 27, 2016

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.