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>
This commit is contained in:
parent
e987df5fe6
commit
f56f764279
@ -35,11 +35,8 @@ static int gently_parse_list_objects_filter(
|
|||||||
{
|
{
|
||||||
const char *v0;
|
const char *v0;
|
||||||
|
|
||||||
if (filter_options->choice) {
|
if (filter_options->choice)
|
||||||
strbuf_addstr(
|
BUG("filter_options already populated");
|
||||||
errbuf, _("multiple filter-specs cannot be combined"));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(arg, "blob:none")) {
|
if (!strcmp(arg, "blob:none")) {
|
||||||
filter_options->choice = LOFC_BLOB_NONE;
|
filter_options->choice = LOFC_BLOB_NONE;
|
||||||
@ -185,6 +182,8 @@ int parse_list_objects_filter(struct list_objects_filter_options *filter_options
|
|||||||
const char *arg)
|
const char *arg)
|
||||||
{
|
{
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
|
if (filter_options->choice)
|
||||||
|
die(_("multiple filter-specs cannot be combined"));
|
||||||
filter_options->filter_spec = strdup(arg);
|
filter_options->filter_spec = strdup(arg);
|
||||||
if (gently_parse_list_objects_filter(filter_options, arg, &buf))
|
if (gently_parse_list_objects_filter(filter_options, arg, &buf))
|
||||||
die("%s", buf.buf);
|
die("%s", buf.buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user