summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorJake Goulding <goulding@vivisimo.com>2009-01-26 09:13:23 -0500
committerJunio C Hamano <gitster@pobox.com>2009-01-28 11:32:27 -0800
commit269defdf30a4beb48f230e36f20d00ee40348ab6 (patch)
tree466b46fb3c837863969c49eed07017184e16ef78 /parse-options.c
parent98ef23b3b106ef8cf4dc0db34e62a39e044cf99b (diff)
downloadgit-269defdf30a4beb48f230e36f20d00ee40348ab6.tar.gz
Make opt_parse_with_commit() non-static
Moving opt_parse_with_commit() from branch to a common location, in preparation for using it in tag. Rename it to match naming convention of other option parsing functions. Signed-off-by: Jake Goulding <goulding@vivisimo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c
index 9eb55cc8b5..4c5d09dd25 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.