[PATCH] Add git-verify-pack command.
[git.git] / verify-pack.c
diff --git a/verify-pack.c b/verify-pack.c
new file mode 100644 (file)
index 0000000..3ae5ac1
--- /dev/null
@@ -0,0 +1,26 @@
+#include "cache.h"
+#include "pack.h"
+
+static int verify_one_pack(char *arg)
+{
+       struct packed_git *g = add_packed_git(arg, strlen(arg));
+       if (!g)
+               return -1;
+       return verify_pack(g);
+}
+
+int main(int ac, char **av)
+{
+       int errs = 0;
+
+       while (1 < ac) {
+               char path[PATH_MAX];
+               strcpy(path, av[1]);
+               if (verify_one_pack(path))
+                       errs++;
+               else
+                       printf("%s: OK\n", av[1]);
+               ac--; av++;
+       }
+       return !!errs;
+}