summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 98ef23b)
raw | patch | inline | side by side (parent: 98ef23b)
author | Jake Goulding <goulding@vivisimo.com> | |
Mon, 26 Jan 2009 14:13:23 +0000 (09:13 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 28 Jan 2009 19:32:27 +0000 (11:32 -0800) |
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>
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>
builtin-branch.c | patch | blob | history | |
parse-options.c | patch | blob | history | |
parse-options.h | patch | blob | history |
diff --git a/builtin-branch.c b/builtin-branch.c
index 02fa38fd3b13b5c17aa23edbfd79f91a052adf76..82d6fb27c937b5fb4f7871c6bae3e584715d7950 100644 (file)
--- a/builtin-branch.c
+++ b/builtin-branch.c
strbuf_release(&newsection);
}
-static int opt_parse_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))
- die("malformed object name %s", arg);
- commit = lookup_commit_reference(sha1);
- if (!commit)
- die("no such commit %s", arg);
- commit_list_insert(commit, opt->value);
- return 0;
-}
-
static int opt_parse_merge_filter(const struct option *opt, const char *arg, int unset)
{
merge_filter = ((opt->long_name[0] == 'n')
OPTION_CALLBACK, 0, "contains", &with_commit, "commit",
"print only branches that contain the commit",
PARSE_OPT_LASTARG_DEFAULT,
- opt_parse_with_commit, (intptr_t)"HEAD",
+ parse_opt_with_commit, (intptr_t)"HEAD",
},
{
OPTION_CALLBACK, 0, "with", &with_commit, "commit",
"print only branches that contain the commit",
PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,
- opt_parse_with_commit, (intptr_t) "HEAD",
+ parse_opt_with_commit, (intptr_t) "HEAD",
},
OPT__ABBREV(&abbrev),
diff --git a/parse-options.c b/parse-options.c
index 9eb55cc8b5182495b687e133a938937db1bc3949..4c5d09dd25aede8ea7e14886f5c17ed847a8f0d9 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
#include "git-compat-util.h"
#include "parse-options.h"
#include "cache.h"
+#include "commit.h"
#define OPT_SHORT 1
#define OPT_UNSET 2
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.
diff --git a/parse-options.h b/parse-options.h
index 034162ec6975cfca8dedadc4eb541212b0d97e43..912290549bcbb03b7e82750a40297fb1a70b8206 100644 (file)
--- a/parse-options.h
+++ b/parse-options.h
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
extern int parse_opt_approxidate_cb(const struct option *, const char *, int);
extern int parse_opt_verbosity_cb(const struct option *, const char *, int);
+extern int parse_opt_with_commit(const struct option *, const char *, int);
#define OPT__VERBOSE(var) OPT_BOOLEAN('v', "verbose", (var), "be verbose")
#define OPT__QUIET(var) OPT_BOOLEAN('q', "quiet", (var), "be quiet")