[PATCH] Exit with status code 2 if we get an exception.
[git/jnareb-git/bp-gitweb.git] / show-index.c
blobc21d660b628a5b6d67b0f56b41fc76a921df340f
1 #include "cache.h"
3 int main(int argc, char **argv)
5 int i;
6 unsigned nr;
7 unsigned int entry[6];
8 static unsigned int top_index[256];
10 if (fread(top_index, sizeof(top_index), 1, stdin) != 1)
11 die("unable to read idex");
12 nr = 0;
13 for (i = 0; i < 256; i++) {
14 unsigned n = ntohl(top_index[i]);
15 if (n < nr)
16 die("corrupt index file");
17 nr = n;
19 for (i = 0; i < nr; i++) {
20 unsigned offset;
22 if (fread(entry, 24, 1, stdin) != 1)
23 die("unable to read entry %u/%u", i, nr);
24 offset = ntohl(entry[0]);
25 printf("%u %s\n", offset, sha1_to_hex((void *)(entry+1)));
27 return 0;