summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8ef038)
raw | patch | inline | side by side (parent: c8ef038)
author | Pierre Habouzit <madcoder@debian.org> | |
Thu, 2 Oct 2008 12:59:19 +0000 (14:59 +0200) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Fri, 3 Oct 2008 01:46:02 +0000 (18:46 -0700) |
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
builtin-merge-base.c | patch | blob | history |
diff --git a/builtin-merge-base.c b/builtin-merge-base.c
index b08da516e491e7089b1bb178e9a4b05c2ab36539..03fc1c211453f1ed09ee2c6b71d438b0bfbf474f 100644 (file)
--- a/builtin-merge-base.c
+++ b/builtin-merge-base.c
#include "builtin.h"
#include "cache.h"
#include "commit.h"
+#include "parse-options.h"
static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
{
return 0;
}
-static const char merge_base_usage[] =
-"git merge-base [--all] <commit-id> <commit-id>...";
+static const char * const merge_base_usage[] = {
+ "git merge-base [--all] <commit-id> <commit-id>...",
+ NULL
+};
static struct commit *get_commit_reference(const char *arg)
{
int rev_nr = 0;
int show_all = 0;
- git_config(git_default_config, NULL);
-
- while (1 < argc && argv[1][0] == '-') {
- const char *arg = argv[1];
- if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
- show_all = 1;
- else
- usage(merge_base_usage);
- argc--; argv++;
- }
- if (argc < 3)
- usage(merge_base_usage);
-
- rev = xmalloc((argc - 1) * sizeof(*rev));
-
- do {
- rev[rev_nr++] = get_commit_reference(argv[1]);
- argc--; argv++;
- } while (argc > 1);
+ struct option options[] = {
+ OPT_BOOLEAN('a', "all", &show_all, "outputs all common ancestors"),
+ OPT_END()
+ };
+ git_config(git_default_config, NULL);
+ argc = parse_options(argc, argv, options, merge_base_usage, 0);
+ if (argc < 2)
+ usage_with_options(merge_base_usage, options);
+ rev = xmalloc(argc * sizeof(*rev));
+ while (argc-- > 0)
+ rev[rev_nr++] = get_commit_reference(*argv++);
return show_merge_base(rev, rev_nr, show_all);
}