git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: santiago@nyu.edu
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, sunshine@sunshineco.com,
	walters@verbum.org, Lukas P <luk.puehringer@gmail.com>,
	Lukas Puehringer <lukas.puehringer@nyu.edu>
Subject: [PATCH 3/6] ref-filter: Expose wrappers for ref_item functions
Date: Thu, 22 Sep 2016 14:53:14 -0400	[thread overview]
Message-ID: <20160922185317.349-4-santiago@nyu.edu> (raw)
In-Reply-To: <20160922185317.349-1-santiago@nyu.edu>

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);
+}
+
 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);
+}
+
 /* Free all memory allocated for ref_array */
 void ref_array_clear(struct ref_array *array)
 {
@@ -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);
+}
+
 /*  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..0f0ffe9 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -107,4 +107,14 @@ 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);
 
+/*
+ * Wrappers exposing the ref_array_item data structure independently
+ * of the container ref_array, e.g. to format-print individual refs.
+ */
+struct ref_array_item *new_ref_item(const char *refname,
+		const unsigned char *objectname, int flag);
+void show_ref_item(struct ref_array_item *ref_item, const char *format,
+		int quote_style);
+void free_ref_item(struct ref_array_item *ref_item);
+
 #endif /*  REF_FILTER_H  */
-- 
2.10.0


  parent reply	other threads:[~2016-09-22 18:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 18:53 [RFC/PATCH 0/6] Add --format to tag verification santiago
2016-09-22 18:53 ` [PATCH 1/6] builtin/tag: move format specifier to global var santiago
2016-09-22 20:23   ` Junio C Hamano
2016-09-22 18:53 ` [PATCH 2/6] gpg-interface: add GPG_VERIFY_QUIET flag santiago
2016-09-22 20:25   ` Junio C Hamano
2016-09-22 20:44   ` Junio C Hamano
2016-09-22 18:53 ` santiago [this message]
2016-09-22 20:50   ` [PATCH 3/6] ref-filter: Expose wrappers for ref_item functions Junio C Hamano
2016-09-22 18:53 ` [PATCH 4/6] tag: add format specifier to gpg_verify_tag santiago
2016-09-22 20:58   ` Junio C Hamano
2016-09-23 14:36     ` Santiago Torres
2016-09-22 18:53 ` [PATCH 5/6] builtin/verify-tag: Add --format to verify-tag santiago
2016-09-22 21:16   ` Junio C Hamano
2016-09-23 14:35     ` Santiago Torres
2016-09-22 18:53 ` [PATCH 6/6] builtin/tag: add --format argument for tag -v santiago
2016-09-22 21:23   ` Junio C Hamano
2016-09-23 14:34     ` Santiago Torres
2016-09-22 19:01 ` [RFC/PATCH 0/6] Add --format to tag verification Stefan Beller
2016-09-24 19:09   ` Jakub Narębski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160922185317.349-4-santiago@nyu.edu \
    --to=santiago@nyu.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=luk.puehringer@gmail.com \
    --cc=lukas.puehringer@nyu.edu \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    --cc=walters@verbum.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).