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

Re: [PATCH 3/6] ref-filter: Expose wrappers for ref_item functions

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2016, 20:50 UTC
Message-ID
<xmqqvaxn3bgx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160922185317.349-4-santiago@nyu.edu>
santiago@nyu.edu writes:
Show 29 quoted lines
> From: Lukas P <luk.puehringer@gmail.com>
>
> Ref-filter functions are useful for printing git object information
> without a format specifier. However, some functions may not want to use
> a complete ref-array, and just a single item instead. Expose
> create/show/free functions for ref_array_items through wrappers around
> the original functions.
>
> Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
> ---
>  ref-filter.c | 20 ++++++++++++++++++++
>  ref-filter.h | 10 ++++++++++
>  2 files changed, 30 insertions(+)
>
> diff --git a/ref-filter.c b/ref-filter.c
> index 9adbb8a..b013799 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -1329,6 +1329,14 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
>  	return ref;
>  }
>  
> +/* Wrapper: Create ref_array_item w/o referencing container in function name */
> +struct ref_array_item *new_ref_item(const char *refname,
> +						 const unsigned char *objectname,
> +						 int flag)
> +{
> +	return new_ref_array_item(refname, objectname, flag);
> +}

Why? As a public function name, new_ref_item() is a horrible one, as there are other structures about "ref" elsewhere in the system. If a new caller needs to be able to get a new ref_array_item, you are better off just exposing it, not an ill-named wrapper.

Show 12 quoted lines
>  static int filter_ref_kind(struct ref_filter *filter, const char *refname)
>  {
>  	unsigned int i;
> @@ -1426,6 +1434,12 @@ static void free_array_item(struct ref_array_item *item)
>  	free(item);
>  }
>  
> +/* Wrapper: Free ref_array_item w/o referencing container in function name */
> +void free_ref_item(struct ref_array_item *ref_item)
> +{
> +	free_array_item(ref_item);
> +}

Again, why? free_array_item() is a horrible name for a public function, and it is OK to rename it to free_ref_array_item() while giving external callers an access to it, so that their names are descriptive enough to convey that they are about ref_array_item structure used in ref-filter API while at the same time making it clear to readers that the two functions with related names are indeed related.

Show 9 quoted lines
> @@ -1637,6 +1651,12 @@ void show_ref_array_item(struct ref_array_item *info, const char *format, int qu
>  	putchar('\n');
>  }
>  
> +/* Wrapper: Show ref_array_item w/o referencing container in function name */
> +void show_ref_item(struct ref_array_item *ref_item, const char *format, int quote_style)
> +{
> +	show_ref_array_item(ref_item, format, quote_style);
> +}
Ditto.
Previous: santiago@nyu.eduNext: santiago@nyu.edu
Message 3 of 19 in “Add --format to tag verification”
  1. 0/6 Add --format to tag verificationsantiago@nyu.edu, Sep 22, 2016
  2. 3/6 ref-filter: Expose wrappers for ref_item functionssantiago@nyu.edu, Sep 22, 2016
  3. Junio C HamanoSep 22, 2016
  4. 6/6 builtin/tag: add --format argument for tag -vsantiago@nyu.edu, Sep 22, 2016
  5. Junio C HamanoSep 22, 2016
  6. Santiago TorresSep 23, 2016
  7. 2/6 gpg-interface: add GPG_VERIFY_QUIET flagsantiago@nyu.edu, Sep 22, 2016
  8. Junio C HamanoSep 22, 2016
  9. Junio C HamanoSep 22, 2016
  10. 4/6 tag: add format specifier to gpg_verify_tagsantiago@nyu.edu, Sep 22, 2016
  11. Junio C HamanoSep 22, 2016
  12. Santiago TorresSep 23, 2016
  13. 1/6 builtin/tag: move format specifier to global varsantiago@nyu.edu, Sep 22, 2016
  14. Junio C HamanoSep 22, 2016
  15. 5/6 builtin/verify-tag: Add --format to verify-tagsantiago@nyu.edu, Sep 22, 2016
  16. Junio C HamanoSep 22, 2016
  17. Santiago TorresSep 23, 2016
  18. Stefan BellerSep 22, 2016
  19. Jakub NarębskiSep 24, 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.