X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=parse-options-cb.c;h=c6679cb2cdee15981ee9ef31c402c358a3727d1e;hb=3b6e73a3b18336cf123993b191e3fab6442bd5a3;hp=16818830e97e099286f3aa259378de1b8e9fc322;hpb=985f59c042320ddf0a506e553d5eef9689ef4c32;p=git-core%2Fgit.git diff --git a/parse-options-cb.c b/parse-options-cb.c index 16818830e..c6679cb2c 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -31,14 +31,14 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) int parse_opt_approxidate_cb(const struct option *opt, const char *arg, int unset) { - *(unsigned long *)(opt->value) = approxidate(arg); + *(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, (unsigned long *)opt->value); + return parse_expiry_date(arg, (timestamp_t *)opt->value); } int parse_opt_color_flag_cb(const struct option *opt, const char *arg, @@ -80,14 +80,14 @@ int parse_opt_verbosity_cb(const struct option *opt, const char *arg, int parse_opt_commits(const struct option *opt, const char *arg, int unset) { - unsigned char sha1[20]; + struct object_id oid; struct commit *commit; if (!arg) return -1; - if (get_sha1(arg, sha1)) + if (get_oid(arg, &oid)) return error("malformed object name %s", arg); - commit = lookup_commit_reference(sha1); + commit = lookup_commit_reference(&oid); if (!commit) return error("no such commit %s", arg); commit_list_insert(commit, opt->value); @@ -96,17 +96,17 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset) int parse_opt_object_name(const struct option *opt, const char *arg, int unset) { - unsigned char sha1[20]; + struct object_id oid; if (unset) { - sha1_array_clear(opt->value); + oid_array_clear(opt->value); return 0; } if (!arg) return -1; - if (get_sha1(arg, sha1)) + if (get_oid(arg, &oid)) return error(_("malformed object name '%s'"), arg); - sha1_array_append(opt->value, sha1); + oid_array_append(opt->value, &oid); return 0; } @@ -159,6 +159,18 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset) } /** + * 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(). + */ +int parse_opt_unknown_cb(const struct option *opt, const char *arg, int unset) +{ + return -2; +} + +/** * Recreates the command-line option in the strbuf. */ static int recreate_opt(struct strbuf *sb, const struct option *opt,