diff options
author | Matthew DeVore <matvore@google.com> | 2019-06-27 15:54:07 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-06-28 08:41:53 -0700 |
commit | 842b00516aebee06fc99c51a663b6587f642d36d (patch) | |
tree | e7d68abf219d4ffaeef30dd12c1e5575375bf994 /list-objects-filter-options.c | |
parent | 7a7c7f4a6d22477e3548021eb3571384651c00be (diff) | |
download | git-842b00516aebee06fc99c51a663b6587f642d36d.tar.gz |
list-objects-filter-options: always supply *errbuf
Making errbuf an optional argument complicates error reporting. Fix this
by making all callers supply an errbuf, even if they may ignore it. This
will be important in follow-up patches where the filter-spec parsing has
more pitfalls and possible errors.
Signed-off-by: Matthew DeVore <matvore@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects-filter-options.c')
-rw-r--r-- | list-objects-filter-options.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c index 1cb20c659c..7c3e397d29 100644 --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@ -30,11 +30,8 @@ static int gently_parse_list_objects_filter( const char *v0; if (filter_options->choice) { - if (errbuf) { - strbuf_addstr( - errbuf, - _("multiple filter-specs cannot be combined")); - } + strbuf_addstr( + errbuf, _("multiple filter-specs cannot be combined")); return 1; } @@ -52,11 +49,7 @@ static int gently_parse_list_objects_filter( } else if (skip_prefix(arg, "tree:", &v0)) { if (!git_parse_ulong(v0, &filter_options->tree_exclude_depth)) { - if (errbuf) { - strbuf_addstr( - errbuf, - _("expected 'tree:<depth>'")); - } + strbuf_addstr(errbuf, _("expected 'tree:<depth>'")); return 1; } filter_options->choice = LOFC_TREE_DEPTH; @@ -90,8 +83,7 @@ static int gently_parse_list_objects_filter( * add new filters */ - if (errbuf) - strbuf_addf(errbuf, _("invalid filter-spec '%s'"), arg); + strbuf_addf(errbuf, _("invalid filter-spec '%s'"), arg); memset(filter_options, 0, sizeof(*filter_options)); return 1; @@ -175,6 +167,8 @@ void partial_clone_register( void partial_clone_get_default_filter_spec( struct list_objects_filter_options *filter_options) { + struct strbuf errbuf = STRBUF_INIT; + /* * Parse default value, but silently ignore it if it is invalid. */ @@ -182,5 +176,6 @@ void partial_clone_get_default_filter_spec( return; gently_parse_list_objects_filter(filter_options, core_partial_clone_filter_default, - NULL); + &errbuf); + strbuf_release(&errbuf); } |