gitweb: whitespace cleanup
[git/dscho.git] / verify-pack.c
blobc99db9dd79315dff4ac19c79b35275cd02397e60
1 #include "cache.h"
2 #include "pack.h"
4 static int verify_one_pack(char *arg, int verbose)
6 int len = strlen(arg);
7 struct packed_git *g;
9 while (1) {
10 /* Should name foo.idx, but foo.pack may be named;
11 * convert it to foo.idx
13 if (!strcmp(arg + len - 5, ".pack")) {
14 strcpy(arg + len - 5, ".idx");
15 len--;
17 /* Should name foo.idx now */
18 if ((g = add_packed_git(arg, len, 1)))
19 break;
20 /* No? did you name just foo? */
21 strcpy(arg + len, ".idx");
22 len += 4;
23 if ((g = add_packed_git(arg, len, 1)))
24 break;
25 return error("packfile %s not found.", arg);
27 return verify_pack(g, verbose);
30 static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
32 int main(int ac, char **av)
34 int errs = 0;
35 int verbose = 0;
36 int no_more_options = 0;
38 while (1 < ac) {
39 char path[PATH_MAX];
41 if (!no_more_options && av[1][0] == '-') {
42 if (!strcmp("-v", av[1]))
43 verbose = 1;
44 else if (!strcmp("--", av[1]))
45 no_more_options = 1;
46 else
47 usage(verify_pack_usage);
49 else {
50 strcpy(path, av[1]);
51 if (verify_one_pack(path, verbose))
52 errs++;
54 ac--; av++;
56 return !!errs;