summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 14ec9cb)
raw | patch | inline | side by side (parent: 14ec9cb)
author | Pierre Habouzit <madcoder@debian.org> | |
Wed, 9 Jul 2008 21:38:34 +0000 (23:38 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 9 Jul 2008 22:14:11 +0000 (15:14 -0700) |
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>
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>
builtin-blame.c | patch | blob | history | |
builtin-shortlog.c | patch | blob | history | |
revision.c | patch | blob | history | |
revision.h | patch | blob | history |
diff --git a/builtin-blame.c b/builtin-blame.c
index 73d26c6e909633f672cdb5318ffba975d2c9cdf8..06c7de429799f4af5303253775f21b7f37723b94 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
parse_options_start(&ctx, argc, argv, PARSE_OPT_KEEP_DASHDASH |
PARSE_OPT_KEEP_ARGV0);
for (;;) {
- int n;
-
switch (parse_options_step(&ctx, options, blame_opt_usage)) {
case PARSE_OPT_HELP:
exit(129);
ctx.argv[0] = "--children";
reverse = 1;
}
- 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(blame_opt_usage, options);
- }
- ctx.argv += n;
- ctx.argc -= n;
+ parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
}
parse_done:
argc = parse_options_end(&ctx);
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 9107bffb9b004407abb5174142c99ce7d1c5e864..01362022c0990cc785d7bcc77f21802c5e75b3e2 100644 (file)
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
PARSE_OPT_KEEP_ARGV0);
for (;;) {
- int n;
switch (parse_options_step(&ctx, options, shortlog_usage)) {
case PARSE_OPT_HELP:
exit(129);
case PARSE_OPT_DONE:
goto parse_done;
}
- n = handle_revision_opt(&rev, ctx.argc, ctx.argv,
- &ctx.cpidx, ctx.out);
- if (n <= 0) {
- error("unknown option `%s'", ctx.argv[0]);
- usage_with_options(shortlog_usage, options);
- }
- ctx.argv += n;
- ctx.argc -= n;
+ parse_revision_opt(&rev, &ctx, options, shortlog_usage);
}
parse_done:
argc = parse_options_end(&ctx);
diff --git a/revision.c b/revision.c
index 4b6925be0869b9e96e16e95aeea2b6eea1abc62b..93918da666abfeb447d07aa96d8e8ad103625f48 100644 (file)
--- a/revision.c
+++ b/revision.c
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];
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.
diff --git a/revision.h b/revision.h
index c44498e3b3dca558002b47a82d8dfe82625b6173..15dc14925ff8c4358af85583b07d13495d5b2cac 100644 (file)
--- a/revision.h
+++ b/revision.h
#ifndef REVISION_H
#define REVISION_H
+#include "parse-options.h"
+
#define SEEN (1u<<0)
#define UNINTERESTING (1u<<1)
#define TREESAME (1u<<2)
extern void init_revisions(struct rev_info *revs, const char *prefix);
extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
-extern int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
- int *unkc, const char **unkv);
+extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
+ const struct option *options,
+ const char * const usagestr[]);
extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
extern int prepare_revision_walk(struct rev_info *revs);