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>
Jake Goulding committed
Jan 26, 2009 at 09:13 UTC
269defdf30a4beb48f230e36f20d00ee40348ab6
3 files changed
+20
-18
builtin-branch.c
+2
-18
@@ -466,22 +466,6 @@ static void rename_branch(const char *oldname, const char *newname, int force)
466
strbuf_release(&newsection);
467
}
468
469
-static int opt_parse_with_commit(const struct option *opt, const char *arg, int unset)
470
-{
471
- unsigned char sha1[20];
472
- struct commit *commit;
473
-
474
- if (!arg)
475
- return -1;
476
- if (get_sha1(arg, sha1))
477
- die("malformed object name %s", arg);
478
- commit = lookup_commit_reference(sha1);
479
- if (!commit)
480
- die("no such commit %s", arg);
481
- commit_list_insert(commit, opt->value);
482
- return 0;
483
-}
484
-
469
static int opt_parse_merge_filter(const struct option *opt, const char *arg, int unset)
470
{
471
merge_filter = ((opt->long_name[0] == 'n')
@@ -517,13 +501,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
501
OPTION_CALLBACK, 0, "contains", &with_commit, "commit",
502
"print only branches that contain the commit",
503
PARSE_OPT_LASTARG_DEFAULT,
520
- opt_parse_with_commit, (intptr_t)"HEAD",
504
+ parse_opt_with_commit, (intptr_t)"HEAD",
505
},
506
{
507
OPTION_CALLBACK, 0, "with", &with_commit, "commit",
508
"print only branches that contain the commit",
509
PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,
526
- opt_parse_with_commit, (intptr_t) "HEAD",
510
+ parse_opt_with_commit, (intptr_t) "HEAD",
511
},
512
OPT__ABBREV(&abbrev),
513
parse-options.c
+17
@@ -1,6 +1,7 @@
1
#include "git-compat-util.h"
2
#include "parse-options.h"
3
#include "cache.h"
4
+#include "commit.h"
5
6
#define OPT_SHORT 1
7
#define OPT_UNSET 2
@@ -506,6 +507,22 @@ int parse_opt_verbosity_cb(const struct option *opt, const char *arg,
507
return 0;
508
}
509
510
+int parse_opt_with_commit(const struct option *opt, const char *arg, int unset)
511
+{
512
+ unsigned char sha1[20];
513
+ struct commit *commit;
514
+
515
+ if (!arg)
516
+ return -1;
517
+ if (get_sha1(arg, sha1))
518
+ return error("malformed object name %s", arg);
519
+ commit = lookup_commit_reference(sha1);
520
+ if (!commit)
521
+ return error("no such commit %s", arg);
522
+ commit_list_insert(commit, opt->value);
523
+ return 0;
524
+}
525
+
526
/*
527
* This should really be OPTION_FILENAME type as a part of
528
* parse_options that take prefix to do this while parsing.
parse-options.h
+1
@@ -151,6 +151,7 @@ extern int parse_options_end(struct parse_opt_ctx_t *ctx);
151
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
152
extern int parse_opt_approxidate_cb(const struct option *, const char *, int);
153
extern int parse_opt_verbosity_cb(const struct option *, const char *, int);
154
+extern int parse_opt_with_commit(const struct option *, const char *, int);
155
156
#define OPT__VERBOSE(var) OPT_BOOLEAN('v', "verbose", (var), "be verbose")
157
#define OPT__QUIET(var) OPT_BOOLEAN('q', "quiet", (var), "be quiet")