Skip to content

Commit 5b2f5d9

Browse files
avargitster
authored andcommitted
parse-options.c: use optbug() instead of BUG() "opts" check
Change the assertions added in bf3ff33 (parse-options: stop abusing 'callback' for lowlevel callbacks, 2019-01-27) to use optbug() instead of BUG(). At this point we're looping over individual options, so if we encounter any issues we'd like to report the offending option. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53ca569 commit 5b2f5d9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

parse-options.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,21 @@ static void parse_options_check(const struct option *opts)
474474
break;
475475
case OPTION_CALLBACK:
476476
if (!opts->callback && !opts->ll_callback)
477-
BUG("OPTION_CALLBACK needs one callback");
478-
if (opts->callback && opts->ll_callback)
479-
BUG("OPTION_CALLBACK can't have two callbacks");
477+
optbug(opts, "OPTION_CALLBACK needs one callback");
478+
else if (opts->callback && opts->ll_callback)
479+
optbug(opts, "OPTION_CALLBACK can't have two callbacks");
480480
break;
481481
case OPTION_LOWLEVEL_CALLBACK:
482482
if (!opts->ll_callback)
483-
BUG("OPTION_LOWLEVEL_CALLBACK needs a callback");
483+
optbug(opts, "OPTION_LOWLEVEL_CALLBACK needs a callback");
484484
if (opts->callback)
485-
BUG("OPTION_LOWLEVEL_CALLBACK needs no high level callback");
485+
optbug(opts, "OPTION_LOWLEVEL_CALLBACK needs no high level callback");
486486
break;
487487
case OPTION_ALIAS:
488-
BUG("OPT_ALIAS() should not remain at this point. "
489-
"Are you using parse_options_step() directly?\n"
490-
"That case is not supported yet.");
488+
optbug(opts, "OPT_ALIAS() should not remain at this point. "
489+
"Are you using parse_options_step() directly?\n"
490+
"That case is not supported yet.");
491+
break;
491492
default:
492493
; /* ok. (usually accepts an argument) */
493494
}

0 commit comments

Comments
 (0)