4 static int verify_one_pack(const char *path
, int verbose
)
8 struct packed_git
*pack
;
11 len
= strlcpy(arg
, path
, PATH_MAX
);
13 return error("name too long: %s", path
);
16 * In addition to "foo.idx" we accept "foo.pack" and "foo";
17 * normalize these forms to "foo.idx" for add_packed_git().
19 if (has_extension(arg
, ".pack")) {
20 strcpy(arg
+ len
- 5, ".idx");
22 } else if (!has_extension(arg
, ".idx")) {
23 if (len
+ 4 >= PATH_MAX
)
24 return error("name too long: %s.idx", arg
);
25 strcpy(arg
+ len
, ".idx");
30 * add_packed_git() uses our buffer (containing "foo.idx") to
31 * build the pack filename ("foo.pack"). Make sure it fits.
33 if (len
+ 1 >= PATH_MAX
) {
35 return error("name too long: %s.pack", arg
);
38 pack
= add_packed_git(arg
, len
, 1);
40 return error("packfile %s not found.", arg
);
42 err
= verify_pack(pack
, verbose
);
48 static const char verify_pack_usage
[] = "git-verify-pack [-v] <pack>...";
50 int main(int ac
, char **av
)
54 int no_more_options
= 0;
58 if (!no_more_options
&& av
[1][0] == '-') {
59 if (!strcmp("-v", av
[1]))
61 else if (!strcmp("--", av
[1]))
64 usage(verify_pack_usage
);
67 if (verify_one_pack(av
[1], verbose
))
75 usage(verify_pack_usage
);