diff options
Diffstat (limited to 'parse-options-cb.c')
-rw-r--r-- | parse-options-cb.c | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c index 3c811e1..bdc7fae 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -1,8 +1,12 @@ #include "git-compat-util.h" #include "parse-options.h" -#include "cache.h" +#include "branch.h" #include "commit.h" #include "color.h" +#include "date.h" +#include "environment.h" +#include "gettext.h" +#include "object-name.h" #include "string-list.h" #include "strvec.h" #include "oid-array.h" @@ -90,7 +94,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset) if (!arg) return -1; - if (get_oid(arg, &oid)) + if (repo_get_oid(the_repository, arg, &oid)) return error("malformed object name %s", arg); commit = lookup_commit_reference(the_repository, &oid); if (!commit) @@ -109,7 +113,7 @@ int parse_opt_commit(const struct option *opt, const char *arg, int unset) if (!arg) return -1; - if (get_oid(arg, &oid)) + if (repo_get_oid(the_repository, arg, &oid)) return error("malformed object name %s", arg); commit = lookup_commit_reference(the_repository, &oid); if (!commit) @@ -128,7 +132,7 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset) } if (!arg) return -1; - if (get_oid(arg, &oid)) + if (repo_get_oid(the_repository, arg, &oid)) return error(_("malformed object name '%s'"), arg); oid_array_append(opt->value, &oid); return 0; @@ -145,7 +149,7 @@ int parse_opt_object_id(const struct option *opt, const char *arg, int unset) } if (!arg) return -1; - if (get_oid(arg, &oid)) + if (repo_get_oid(the_repository, arg, &oid)) return error(_("malformed object name '%s'"), arg); *target = oid; return 0; @@ -207,24 +211,27 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset) return 0; } -int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset) +int parse_opt_strvec(const struct option *opt, const char *arg, int unset) { + struct strvec *v = opt->value; + + if (unset) { + strvec_clear(v); + return 0; + } + + if (!arg) + return -1; + + strvec_push(v, arg); return 0; } -/** - * Report that the option is unknown, so that other code can handle - * it. This can be used as a callback together with - * OPTION_LOWLEVEL_CALLBACK to allow an option to be documented in the - * "-h" output even if it's not being handled directly by - * parse_options(). - */ -enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx, - const struct option *opt, - const char *arg, int unset) +int parse_opt_noop_cb(const struct option *opt UNUSED, + const char *arg UNUSED, + int unset UNUSED) { - BUG_ON_OPT_ARG(arg); - return PARSE_OPT_UNKNOWN; + return 0; } /** @@ -293,3 +300,18 @@ int parse_opt_passthru_argv(const struct option *opt, const char *arg, int unset return 0; } + +int parse_opt_tracking_mode(const struct option *opt, const char *arg, int unset) +{ + if (unset) + *(enum branch_track *)opt->value = BRANCH_TRACK_NEVER; + else if (!arg || !strcmp(arg, "direct")) + *(enum branch_track *)opt->value = BRANCH_TRACK_EXPLICIT; + else if (!strcmp(arg, "inherit")) + *(enum branch_track *)opt->value = BRANCH_TRACK_INHERIT; + else + return error(_("option `%s' expects \"%s\" or \"%s\""), + "--track", "direct", "inherit"); + + return 0; +} |