Skip to content

Commit e1ac4a4

Browse files
matvoregitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65cee9a commit e1ac4a4

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

list-objects-filter-options.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ static int gently_parse_list_objects_filter(
3030
const char *v0;
3131

3232
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"));
3835
return 1;
3936
}
4037

@@ -52,11 +49,7 @@ static int gently_parse_list_objects_filter(
5249

5350
} else if (skip_prefix(arg, "tree:", &v0)) {
5451
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>'"));
6053
return 1;
6154
}
6255
filter_options->choice = LOFC_TREE_DEPTH;
@@ -90,8 +83,7 @@ static int gently_parse_list_objects_filter(
9083
* add new filters
9184
*/
9285

93-
if (errbuf)
94-
strbuf_addf(errbuf, "invalid filter-spec '%s'", arg);
86+
strbuf_addf(errbuf, "invalid filter-spec '%s'", arg);
9587

9688
memset(filter_options, 0, sizeof(*filter_options));
9789
return 1;
@@ -175,12 +167,15 @@ void partial_clone_register(
175167
void partial_clone_get_default_filter_spec(
176168
struct list_objects_filter_options *filter_options)
177169
{
170+
struct strbuf errbuf = STRBUF_INIT;
171+
178172
/*
179173
* Parse default value, but silently ignore it if it is invalid.
180174
*/
181175
if (!core_partial_clone_filter_default)
182176
return;
183177
gently_parse_list_objects_filter(filter_options,
184178
core_partial_clone_filter_default,
185-
NULL);
179+
&errbuf);
180+
strbuf_release(&errbuf);
186181
}

0 commit comments

Comments
 (0)