Skip to content

Commit d3d10e5

Browse files
matvoregitster
authored andcommitted
list-objects-filter-options: move error check up
Move the check that filter_options->choice is set to higher in the call stack. This can only be set when the gentle parse function is called from one of the two call sites. This is important because in an upcoming patch this may or may not be an error, and whether it is an error is only known to the parse_list_objects_filter function. Signed-off-by: Matthew DeVore <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e43301 commit d3d10e5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

list-objects-filter-options.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ static int gently_parse_list_objects_filter(
3535
{
3636
const char *v0;
3737

38-
if (filter_options->choice) {
39-
strbuf_addstr(
40-
errbuf, _("multiple filter-specs cannot be combined"));
41-
return 1;
42-
}
38+
if (filter_options->choice)
39+
BUG("filter_options already populated");
4340

4441
if (!strcmp(arg, "blob:none")) {
4542
filter_options->choice = LOFC_BLOB_NONE;
@@ -185,6 +182,8 @@ int parse_list_objects_filter(struct list_objects_filter_options *filter_options
185182
const char *arg)
186183
{
187184
struct strbuf buf = STRBUF_INIT;
185+
if (filter_options->choice)
186+
die(_("multiple filter-specs cannot be combined"));
188187
filter_options->filter_spec = strdup(arg);
189188
if (gently_parse_list_objects_filter(filter_options, arg, &buf))
190189
die("%s", buf.buf);

0 commit comments

Comments
 (0)