summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2008-07-09 23:38:34 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-09 15:14:11 -0700
commit6b61ec0564993d2e60f7eb56c0f0fd9c313d5e2c (patch)
tree75d14aa978400c730ae6494055f189c04535df67 /revision.c
parent14ec9cbdae1991a14aa1cce251e44ea5cfee5ade (diff)
downloadgit-6b61ec0564993d2e60f7eb56c0f0fd9c313d5e2c.tar.gz
revisions: refactor handle_revision_opt into parse_revision_opt.
It seems we're using handle_revision_opt the same way each time, have a wrapper around it that does the 9-liner we copy each time instead. handle_revision_opt can be static in the module for now, it's always possible to make it public again if needed. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/revision.c b/revision.c
index 4b6925be08..93918da666 100644
--- a/revision.c
+++ b/revision.c
@@ -957,8 +957,8 @@ static void add_ignore_packed(struct rev_info *revs, const char *name)
revs->ignore_packed[num] = NULL;
}
-int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
- int *unkc, const char **unkv)
+static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
+ int *unkc, const char **unkv)
{
const char *arg = argv[0];
@@ -1163,6 +1163,20 @@ int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
return 1;
}
+void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
+ const struct option *options,
+ const char * const usagestr[])
+{
+ int n = handle_revision_opt(revs, ctx->argc, ctx->argv,
+ &ctx->cpidx, ctx->out);
+ if (n <= 0) {
+ error("unknown option `%s'", ctx->argv[0]);
+ usage_with_options(usagestr, options);
+ }
+ ctx->argv += n;
+ ctx->argc -= n;
+}
+
/*
* Parse revision information, filling in the "rev_info" structure,
* and removing the used arguments from the argument list.