]> git.ipfire.org Git - thirdparty/git.git/blame - verify-pack.c
Illustration: "Git Diff Types"
[thirdparty/git.git] / verify-pack.c
CommitLineData
f9253394
JH
1#include "cache.h"
2#include "pack.h"
3
f3bf9224 4static int verify_one_pack(char *arg, int verbose)
f9253394 5{
f3bf9224
JH
6 int len = strlen(arg);
7 struct packed_git *g;
8
9 while (1) {
10 /* Should name foo.idx, but foo.pack may be named;
11 * convert it to foo.idx
12 */
13 if (!strcmp(arg + len - 5, ".pack")) {
14 strcpy(arg + len - 5, ".idx");
15 len--;
16 }
17 /* Should name foo.idx now */
9d835df2 18 if ((g = add_packed_git(arg, len, 1)))
f3bf9224
JH
19 break;
20 /* No? did you name just foo? */
21 strcpy(arg + len, ".idx");
22 len += 4;
9d835df2 23 if ((g = add_packed_git(arg, len, 1)))
f3bf9224
JH
24 break;
25 return error("packfile %s not found.", arg);
26 }
27 return verify_pack(g, verbose);
f9253394
JH
28}
29
4d1f1190 30static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
f3bf9224 31
f9253394
JH
32int main(int ac, char **av)
33{
34 int errs = 0;
f3bf9224
JH
35 int verbose = 0;
36 int no_more_options = 0;
f9253394
JH
37
38 while (1 < ac) {
39 char path[PATH_MAX];
f3bf9224
JH
40
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);
48 }
49 else {
50 strcpy(path, av[1]);
51 if (verify_one_pack(path, verbose))
52 errs++;
53 }
f9253394
JH
54 ac--; av++;
55 }
56 return !!errs;
57}