aboutsummaryrefslogtreecommitdiffstats
path: root/show-index.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-05 17:08:02 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-05 17:08:02 -0700
commit0271611e390c3aaacc4f4f0529c10c7b095ed682 (patch)
tree1cc299c2fe21496af1169311b09f15da9d5b75ab /show-index.c
parent291ec0f2d2ce65e5ccb876b46d6468af49ddb82e (diff)
downloadgit-0271611e390c3aaacc4f4f0529c10c7b095ed682.tar.gz
Add a "git-show-index" helper that shows the contents of a pack index
This was invaluable for debugging the zero-sized compression issue, and might be useful for scripting too, if people want to see the contents of a pack.
Diffstat (limited to 'show-index.c')
-rw-r--r--show-index.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/show-index.c b/show-index.c
new file mode 100644
index 0000000000..c21d660b62
--- /dev/null
+++ b/show-index.c
@@ -0,0 +1,28 @@
+#include "cache.h"
+
+int main(int argc, char **argv)
+{
+ int i;
+ unsigned nr;
+ unsigned int entry[6];
+ static unsigned int top_index[256];
+
+ if (fread(top_index, sizeof(top_index), 1, stdin) != 1)
+ die("unable to read idex");
+ nr = 0;
+ for (i = 0; i < 256; i++) {
+ unsigned n = ntohl(top_index[i]);
+ if (n < nr)
+ die("corrupt index file");
+ nr = n;
+ }
+ for (i = 0; i < nr; i++) {
+ unsigned offset;
+
+ if (fread(entry, 24, 1, stdin) != 1)
+ die("unable to read entry %u/%u", i, nr);
+ offset = ntohl(entry[0]);
+ printf("%u %s\n", offset, sha1_to_hex((void *)(entry+1)));
+ }
+ return 0;
+}