diff options
author | Jeff King <peff@peff.net> | 2017-07-13 11:02:44 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-13 12:42:51 -0700 |
commit | 18a2565016d45538345a06cd9b912040b5581fc1 (patch) | |
tree | db5dbf1a5d573cbc64312997b24cb2b0bb9282a1 /ref-filter.c | |
parent | ref-filter: move need_color_reset_at_eol into ref_format (diff) | |
download | tgif-18a2565016d45538345a06cd9b912040b5581fc1.tar.xz |
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.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/ref-filter.c b/ref-filter.c index 178396e1f3..4321212197 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; } |