summaryrefslogtreecommitdiff
path: root/ref-filter.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-07-13 15:02:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-13 19:42:51 (GMT)
commit18a2565016d45538345a06cd9b912040b5581fc1 (patch)
treedb5dbf1a5d573cbc64312997b24cb2b0bb9282a1 /ref-filter.c
parentbf285ae6dbfa8e2b847940e6ad987ff3cbe40712 (diff)
downloadgit-18a2565016d45538345a06cd9b912040b5581fc1.zip
git-18a2565016d45538345a06cd9b912040b5581fc1.tar.gz
git-18a2565016d45538345a06cd9b912040b5581fc1.tar.bz2
ref-filter: provide a function for parsing sort options
The ref-filter module currently provides a callback suitable for parsing command-line --sort options. But since git-tag also supports the tag.sort config option, it needs a function whose implementation is quite similar, but with a slightly different interface. The end result is that builtin/tag.c has a copy-paste of parse_opt_ref_sorting(). Instead, let's provide a function to parse an arbitrary sort string, which we can then trivially wrap to make the parse_opt variant. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ref-filter.c b/ref-filter.c
index 178396e..4321212 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2126,15 +2126,11 @@ struct ref_sorting *ref_default_sorting(void)
return sorting;
}
-int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)
+void parse_ref_sorting(struct ref_sorting **sorting_tail, const char *arg)
{
- struct ref_sorting **sorting_tail = opt->value;
struct ref_sorting *s;
int len;
- if (!arg) /* should --no-sort void the list ? */
- return -1;
-
s = xcalloc(1, sizeof(*s));
s->next = *sorting_tail;
*sorting_tail = s;
@@ -2148,6 +2144,13 @@ int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)
s->version = 1;
len = strlen(arg);
s->atom = parse_ref_filter_atom(arg, arg+len);
+}
+
+int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)
+{
+ if (!arg) /* should --no-sort void the list ? */
+ return -1;
+ parse_ref_sorting(opt->value, arg);
return 0;
}