shortlog: prompt when reading from terminal by mistake
[git/git-svn.git] / show-index.c
bloba30a2de5d13931c590169cf30bd7004e23f2df1b
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 index");
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;