5 static int verify_one_pack(const char *path
, int verbose
)
9 struct packed_git
*pack
;
12 len
= strlcpy(arg
, path
, PATH_MAX
);
14 return error("name too long: %s", path
);
17 * In addition to "foo.idx" we accept "foo.pack" and "foo";
18 * normalize these forms to "foo.idx" for add_packed_git().
20 if (has_extension(arg
, ".pack")) {
21 strcpy(arg
+ len
- 5, ".idx");
23 } else if (!has_extension(arg
, ".idx")) {
24 if (len
+ 4 >= PATH_MAX
)
25 return error("name too long: %s.idx", arg
);
26 strcpy(arg
+ len
, ".idx");
31 * add_packed_git() uses our buffer (containing "foo.idx") to
32 * build the pack filename ("foo.pack"). Make sure it fits.
34 if (len
+ 1 >= PATH_MAX
) {
36 return error("name too long: %s.pack", arg
);
39 pack
= add_packed_git(arg
, len
, 1);
41 return error("packfile %s not found.", arg
);
43 install_packed_git(pack
);
44 err
= verify_pack(pack
, verbose
);
49 static const char verify_pack_usage
[] = "git-verify-pack [-v] <pack>...";
51 int cmd_verify_pack(int argc
, const char **argv
, const char *prefix
)
55 int no_more_options
= 0;
58 git_config(git_default_config
);
60 if (!no_more_options
&& argv
[1][0] == '-') {
61 if (!strcmp("-v", argv
[1]))
63 else if (!strcmp("--", argv
[1]))
66 usage(verify_pack_usage
);
69 if (verify_one_pack(argv
[1], verbose
))
77 usage(verify_pack_usage
);