summaryrefslogtreecommitdiff
path: root/builtin-count-objects.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-11-02 16:42:23 -0700
committerJunio C Hamano <gitster@pobox.com>2007-11-02 16:42:23 -0700
commit3d66dc9657f195cb241387a87bcdd5709abd8a21 (patch)
treed60c114be03184c94b040ab531d2908ba1f66849 /builtin-count-objects.c
parent265ae188267fda441f92e513fb89641f78e982fd (diff)
parent44c637c8021e44253f0f8cb17391092e08b39e73 (diff)
downloadgit-3d66dc9657f195cb241387a87bcdd5709abd8a21.tar.gz
Merge branch 'ph/parseopt'
* ph/parseopt: (24 commits) gc: use parse_options Fixed a command line option type for builtin-fsck.c Make builtin-pack-refs.c use parse_options. Make builtin-name-rev.c use parse_options. Make builtin-count-objects.c use parse_options. Make builtin-fsck.c use parse_options. Update manpages to reflect new short and long option aliases Make builtin-for-each-ref.c use parse-opts. Make builtin-symbolic-ref.c use parse_options. Make builtin-update-ref.c use parse_options Make builtin-revert.c use parse_options. Make builtin-describe.c use parse_options Make builtin-branch.c use parse_options. Make builtin-mv.c use parse-options Make builtin-rm.c use parse_options. Port builtin-add.c to use the new option parser. parse-options: allow callbacks to take no arguments at all. parse-options: Allow abbreviated options when unambiguous Add shortcuts for very often used options. parse-options: make some arguments optional, add callbacks. ... Conflicts: Makefile builtin-add.c
Diffstat (limited to 'builtin-count-objects.c')
-rw-r--r--builtin-count-objects.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index 4274ec1950..f00306fb67 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -6,8 +6,7 @@
#include "cache.h"
#include "builtin.h"
-
-static const char count_objects_usage[] = "git-count-objects [-v]";
+#include "parse-options.h"
static void count_objects(DIR *d, char *path, int len, int verbose,
unsigned long *loose,
@@ -67,29 +66,28 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
}
}
-int cmd_count_objects(int ac, const char **av, const char *prefix)
+static char const * const count_objects_usage[] = {
+ "git-count-objects [-v]",
+ NULL
+};
+
+int cmd_count_objects(int argc, const char **argv, const char *prefix)
{
- int i;
- int verbose = 0;
+ int i, verbose = 0;
const char *objdir = get_object_directory();
int len = strlen(objdir);
char *path = xmalloc(len + 50);
unsigned long loose = 0, packed = 0, packed_loose = 0, garbage = 0;
unsigned long loose_size = 0;
+ struct option opts[] = {
+ OPT__VERBOSE(&verbose),
+ OPT_END(),
+ };
- for (i = 1; i < ac; i++) {
- const char *arg = av[i];
- if (*arg != '-')
- break;
- else if (!strcmp(arg, "-v"))
- verbose = 1;
- else
- usage(count_objects_usage);
- }
-
+ argc = parse_options(argc, argv, opts, count_objects_usage, 0);
/* we do not take arguments other than flags for now */
- if (i < ac)
- usage(count_objects_usage);
+ if (argc)
+ usage_with_options(count_objects_usage, opts);
memcpy(path, objdir, len);
if (len && objdir[len-1] != '/')
path[len++] = '/';