{"thread":{"id":"17313","subject":"[PATCH 1/3] Make opt_parse_with_commit non-static","startedAt":"2009-01-23T00:48:42Z","lastAt":"2009-01-23T00:48:42Z","messageCount":1,"participants":["Jake Goulding"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"101589","messageId":"497913EA.6090706@vivisimo.com","threadId":"17313","inReplyTo":null,"subject":"[PATCH 1/3] Make opt_parse_with_commit non-static","fromName":"Jake Goulding","fromEmail":"goulding@vivisimo.com","sentAt":"2009-01-23T00:48:42Z","receivedAt":"2009-01-23T00:48:42Z","isPatch":true,"sender":{"key":"goulding@vivisimo.com","avatar":"https://gravatar.com/avatar/d8938ff226c618b80857e27f7e0a2d4335215bfb9733c321b8dd30c660b7f1e9?d=mp&s=160"},"body":"Moving opt_parse_with_commit from branch to a common location in\npreparation for using it in tag. Renamed it to correspond to naming\nconvention of other option parsing functions.\n\nSigned-off-by: Jake Goulding <goulding@vivisimo.com>\n---\n builtin-branch.c |   20 ++------------------\n parse-options.c  |   17 +++++++++++++++++\n parse-options.h  |    1 +\n 3 files changed, 20 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 02fa38f..82d6fb2 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -466,22 +466,6 @@ static void rename_branch(const char *oldname,\nconst char *newname, int force)\n \tstrbuf_release(&newsection);\n }\n\n-static int opt_parse_with_commit(const struct option *opt, const char\n*arg, int unset)\n-{\n-\tunsigned char sha1[20];\n-\tstruct commit *commit;\n-\n-\tif (!arg)\n-\t\treturn -1;\n-\tif (get_sha1(arg, sha1))\n-\t\tdie(\"malformed object name %s\", arg);\n-\tcommit = lookup_commit_reference(sha1);\n-\tif (!commit)\n-\t\tdie(\"no such commit %s\", arg);\n-\tcommit_list_insert(commit, opt->value);\n-\treturn 0;\n-}\n-\n static int opt_parse_merge_filter(const struct option *opt, const char\n*arg, int unset)\n {\n \tmerge_filter = ((opt->long_name[0] == 'n')\n@@ -517,13 +501,13 @@ int cmd_branch(int argc, const char **argv, const\nchar *prefix)\n \t\t\tOPTION_CALLBACK, 0, \"contains\", &with_commit, \"commit\",\n \t\t\t\"print only branches that contain the commit\",\n \t\t\tPARSE_OPT_LASTARG_DEFAULT,\n-\t\t\topt_parse_with_commit, (intptr_t)\"HEAD\",\n+\t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n \t\t},\n \t\t{\n \t\t\tOPTION_CALLBACK, 0, \"with\", &with_commit, \"commit\",\n \t\t\t\"print only branches that contain the commit\",\n \t\t\tPARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,\n-\t\t\topt_parse_with_commit, (intptr_t) \"HEAD\",\n+\t\t\tparse_opt_with_commit, (intptr_t) \"HEAD\",\n \t\t},\n \t\tOPT__ABBREV(&abbrev),\n\ndiff --git a/parse-options.c b/parse-options.c\nindex 9eb55cc..4c5d09d 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -1,6 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"parse-options.h\"\n #include \"cache.h\"\n+#include \"commit.h\"\n\n #define OPT_SHORT 1\n #define OPT_UNSET 2\n@@ -506,6 +507,22 @@ int parse_opt_verbosity_cb(const struct option\n*opt, const char *arg,\n \treturn 0;\n }\n\n+int parse_opt_with_commit(const struct option *opt, const char *arg,\nint unset)\n+{\n+\tunsigned char sha1[20];\n+\tstruct commit *commit;\n+\n+\tif (!arg)\n+\t\treturn -1;\n+\tif (get_sha1(arg, sha1))\n+\t\treturn error(\"malformed object name %s\", arg);\n+\tcommit = lookup_commit_reference(sha1);\n+\tif (!commit)\n+\t\treturn error(\"no such commit %s\", arg);\n+\tcommit_list_insert(commit, opt->value);\n+\treturn 0;\n+}\n+\n /*\n  * This should really be OPTION_FILENAME type as a part of\n  * parse_options that take prefix to do this while parsing.\ndiff --git a/parse-options.h b/parse-options.h\nindex 034162e..9122905 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -151,6 +151,7 @@ extern int parse_options_end(struct parse_opt_ctx_t\n*ctx);\n extern int parse_opt_abbrev_cb(const struct option *, const char *, int);\n extern int parse_opt_approxidate_cb(const struct option *, const char\n*, int);\n extern int parse_opt_verbosity_cb(const struct option *, const char *,\nint);\n+extern int parse_opt_with_commit(const struct option *, const char *, int);\n\n #define OPT__VERBOSE(var)  OPT_BOOLEAN('v', \"verbose\", (var), \"be verbose\")\n #define OPT__QUIET(var)    OPT_BOOLEAN('q', \"quiet\",   (var), \"be quiet\")\n-- \n1.6.0.4\n"}]}