X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=parse-options.c;h=4c5d09dd25aede8ea7e14886f5c17ed847a8f0d9;hb=161261b12b3777bc78ef3fbe84ccf595dd195704;hp=9eb55cc8b5182495b687e133a938937db1bc3949;hpb=914186a5c3dd687ad157dbda1518a58b58797391;p=git.git diff --git a/parse-options.c b/parse-options.c index 9eb55cc8b..4c5d09dd2 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "parse-options.h" #include "cache.h" +#include "commit.h" #define OPT_SHORT 1 #define OPT_UNSET 2 @@ -506,6 +507,22 @@ int parse_opt_verbosity_cb(const struct option *opt, const char *arg, return 0; } +int parse_opt_with_commit(const struct option *opt, const char *arg, int unset) +{ + unsigned char sha1[20]; + struct commit *commit; + + if (!arg) + return -1; + if (get_sha1(arg, sha1)) + return error("malformed object name %s", arg); + commit = lookup_commit_reference(sha1); + if (!commit) + return error("no such commit %s", arg); + commit_list_insert(commit, opt->value); + return 0; +} + /* * This should really be OPTION_FILENAME type as a part of * parse_options that take prefix to do this while parsing.