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 <matvore@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthew DeVore committed
Jun 27, 2019 at 15:54 UTC
f56f764279be2433ecf3cb3a484210bcaffea70c
1 file changed
+4
-5
list-objects-filter-options.c
+4
-5
@@ -35,11 +35,8 @@ static int gently_parse_list_objects_filter(
35
{
36
const char *v0;
37
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");
40
41
if (!strcmp(arg, "blob:none")) {
42
filter_options->choice = LOFC_BLOB_NONE;
@@ -185,6 +182,8 @@ int parse_list_objects_filter(struct list_objects_filter_options *filter_options
182
const char *arg)
183
{
184
struct strbuf buf = STRBUF_INIT;
185
+ if (filter_options->choice)
186
+ die(_("multiple filter-specs cannot be combined"));
187
filter_options->filter_spec = strdup(arg);
188
if (gently_parse_list_objects_filter(filter_options, arg, &buf))
189
die("%s", buf.buf);