2005-06-29 09:51:27 +00:00
|
|
|
#include "cache.h"
|
|
|
|
#include "pack.h"
|
|
|
|
|
2005-07-01 00:15:39 +00:00
|
|
|
static int verify_one_pack(char *arg, int verbose)
|
2005-06-29 09:51:27 +00:00
|
|
|
{
|
2005-07-01 00:15:39 +00:00
|
|
|
int len = strlen(arg);
|
|
|
|
struct packed_git *g;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
/* Should name foo.idx, but foo.pack may be named;
|
|
|
|
* convert it to foo.idx
|
|
|
|
*/
|
|
|
|
if (!strcmp(arg + len - 5, ".pack")) {
|
|
|
|
strcpy(arg + len - 5, ".idx");
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
/* Should name foo.idx now */
|
2005-10-13 22:38:28 +00:00
|
|
|
if ((g = add_packed_git(arg, len, 1)))
|
2005-07-01 00:15:39 +00:00
|
|
|
break;
|
|
|
|
/* No? did you name just foo? */
|
|
|
|
strcpy(arg + len, ".idx");
|
|
|
|
len += 4;
|
2005-10-13 22:38:28 +00:00
|
|
|
if ((g = add_packed_git(arg, len, 1)))
|
2005-07-01 00:15:39 +00:00
|
|
|
break;
|
|
|
|
return error("packfile %s not found.", arg);
|
|
|
|
}
|
|
|
|
return verify_pack(g, verbose);
|
2005-06-29 09:51:27 +00:00
|
|
|
}
|
|
|
|
|
2005-07-29 09:01:26 +00:00
|
|
|
static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
|
2005-07-01 00:15:39 +00:00
|
|
|
|
2005-06-29 09:51:27 +00:00
|
|
|
int main(int ac, char **av)
|
|
|
|
{
|
|
|
|
int errs = 0;
|
2005-07-01 00:15:39 +00:00
|
|
|
int verbose = 0;
|
|
|
|
int no_more_options = 0;
|
2005-06-29 09:51:27 +00:00
|
|
|
|
|
|
|
while (1 < ac) {
|
|
|
|
char path[PATH_MAX];
|
2005-07-01 00:15:39 +00:00
|
|
|
|
|
|
|
if (!no_more_options && av[1][0] == '-') {
|
|
|
|
if (!strcmp("-v", av[1]))
|
|
|
|
verbose = 1;
|
|
|
|
else if (!strcmp("--", av[1]))
|
|
|
|
no_more_options = 1;
|
|
|
|
else
|
|
|
|
usage(verify_pack_usage);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
strcpy(path, av[1]);
|
|
|
|
if (verify_one_pack(path, verbose))
|
|
|
|
errs++;
|
|
|
|
}
|
2005-06-29 09:51:27 +00:00
|
|
|
ac--; av++;
|
|
|
|
}
|
|
|
|
return !!errs;
|
|
|
|
}
|