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>
Matthew DeVore committed
Jun 27, 2019 at 15:54 UTC
842b00516aebee06fc99c51a663b6587f642d36d
1 file changed
+8
-13
list-objects-filter-options.c
+8
-13
@@ -30,11 +30,8 @@ static int gently_parse_list_objects_filter(
30
const char *v0;
31
32
if (filter_options->choice) {
33
- if (errbuf) {
34
- strbuf_addstr(
35
- errbuf,
36
- _("multiple filter-specs cannot be combined"));
37
- }
33
+ strbuf_addstr(
34
+ errbuf, _("multiple filter-specs cannot be combined"));
35
return 1;
36
}
37
@@ -52,11 +49,7 @@ static int gently_parse_list_objects_filter(
49
50
} else if (skip_prefix(arg, "tree:", &v0)) {
51
if (!git_parse_ulong(v0, &filter_options->tree_exclude_depth)) {
55
- if (errbuf) {
56
- strbuf_addstr(
57
- errbuf,
58
- _("expected 'tree:<depth>'"));
59
- }
52
+ strbuf_addstr(errbuf, _("expected 'tree:<depth>'"));
53
return 1;
54
}
55
filter_options->choice = LOFC_TREE_DEPTH;
@@ -90,8 +83,7 @@ static int gently_parse_list_objects_filter(
83
* add new filters
84
*/
85
93
- if (errbuf)
94
- strbuf_addf(errbuf, _("invalid filter-spec '%s'"), arg);
86
+ strbuf_addf(errbuf, _("invalid filter-spec '%s'"), arg);
87
88
memset(filter_options, 0, sizeof(*filter_options));
89
return 1;
@@ -175,6 +167,8 @@ void partial_clone_register(
167
void partial_clone_get_default_filter_spec(
168
struct list_objects_filter_options *filter_options)
169
{
170
+ struct strbuf errbuf = STRBUF_INIT;
171
+
172
/*
173
* Parse default value, but silently ignore it if it is invalid.
174
*/
@@ -182,5 +176,6 @@ void partial_clone_get_default_filter_spec(
176
return;
177
gently_parse_list_objects_filter(filter_options,
178
core_partial_clone_filter_default,
185
- NULL);
179
+ &errbuf);
180
+ strbuf_release(&errbuf);
181
}