diff options
Diffstat (limited to 'parse-options-cb.c')
-rw-r--r-- | parse-options-cb.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c index c6679cb2cd..e2f3eaed07 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -18,7 +18,8 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) } else { v = strtol(arg, (char **)&arg, 10); if (*arg) - return opterror(opt, "expects a numerical value", 0); + return error(_("option `%s' expects a numerical value"), + opt->long_name); if (v && v < MINIMUM_ABBREV) v = MINIMUM_ABBREV; else if (v > 40) @@ -28,17 +29,14 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) return 0; } -int parse_opt_approxidate_cb(const struct option *opt, const char *arg, - int unset) -{ - *(timestamp_t *)(opt->value) = approxidate(arg); - return 0; -} - int parse_opt_expiry_date_cb(const struct option *opt, const char *arg, int unset) { - return parse_expiry_date(arg, (timestamp_t *)opt->value); + if (unset) + arg = "never"; + if (parse_expiry_date(arg, (timestamp_t *)opt->value)) + die(_("malformed expiration date '%s'"), arg); + return 0; } int parse_opt_color_flag_cb(const struct option *opt, const char *arg, @@ -50,8 +48,8 @@ int parse_opt_color_flag_cb(const struct option *opt, const char *arg, arg = unset ? "never" : (const char *)opt->defval; value = git_config_colorbool(NULL, arg); if (value < 0) - return opterror(opt, - "expects \"always\", \"auto\", or \"never\"", 0); + return error(_("option `%s' expects \"always\", \"auto\", or \"never\""), + opt->long_name); *(int *)opt->value = value; return 0; } @@ -61,6 +59,8 @@ int parse_opt_verbosity_cb(const struct option *opt, const char *arg, { int *target = opt->value; + BUG_ON_OPT_ARG(arg); + if (unset) /* --no-quiet, --no-verbose */ *target = 0; @@ -83,11 +83,13 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset) struct object_id oid; struct commit *commit; + BUG_ON_OPT_NEG(unset); + if (!arg) return -1; if (get_oid(arg, &oid)) return error("malformed object name %s", arg); - commit = lookup_commit_reference(&oid); + commit = lookup_commit_reference(the_repository, &oid); if (!commit) return error("no such commit %s", arg); commit_list_insert(commit, opt->value); @@ -113,6 +115,9 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset) int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) { int *target = opt->value; + + BUG_ON_OPT_ARG(arg); + *target = unset ? 2 : 1; return 0; } |