summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a6e5642)
raw | patch | inline | side by side (parent: a6e5642)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 24 Apr 2006 03:20:25 +0000 (20:20 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 24 Apr 2006 07:26:31 +0000 (00:26 -0700) |
This was useful in diagnosing the corrupt index.aux format
problem. But do not bother building or installing it by
default.
Signed-off-by: Junio C Hamano <junkio@cox.net>
problem. But do not bother building or installing it by
default.
Signed-off-by: Junio C Hamano <junkio@cox.net>
.gitignore | patch | blob | history | |
Makefile | patch | blob | history | |
dump-cache-tree.c | [new file with mode: 0644] | patch | blob |
diff --git a/.gitignore b/.gitignore
index b5959d63116aa1e3e900f43a137295b47376e1e0..7906909b306f80ed74d6e53bb8514a889057194c 100644 (file)
--- a/.gitignore
+++ b/.gitignore
git-core-*/?*
test-date
test-delta
+test-dump-cache-tree
common-cmds.h
*.tar.gz
*.dsc
diff --git a/Makefile b/Makefile
index 518c3c176b8b4f6678f4aa05fe6e9e329fe91467..1aa96f4f2e166afa3234264fdb4832bdbd535677 100644 (file)
--- a/Makefile
+++ b/Makefile
test-delta$X: test-delta.c diff-delta.o patch-delta.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^ -lz
+test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
+ $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+
check:
for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
diff --git a/dump-cache-tree.c b/dump-cache-tree.c
--- /dev/null
+++ b/dump-cache-tree.c
@@ -0,0 +1,32 @@
+#include "cache.h"
+#include "tree.h"
+#include "cache-tree.h"
+
+static unsigned char active_cache_sha1[20];
+static struct cache_tree *active_cache_tree;
+
+static void dump_cache_tree(struct cache_tree *it, const char *pfx)
+{
+ int i;
+ if (it->entry_count < 0)
+ printf("%-40s %s\n", "invalid", pfx);
+ else
+ printf("%s %s (%d entries)\n",
+ sha1_to_hex(it->sha1),
+ pfx, it->entry_count);
+ for (i = 0; i < it->subtree_nr; i++) {
+ char path[PATH_MAX];
+ struct cache_tree_sub *down = it->down[i];
+ sprintf(path, "%s%.*s/", pfx, down->namelen, down->name);
+ dump_cache_tree(down->cache_tree, path);
+ }
+}
+
+int main(int ac, char **av)
+{
+ if (read_cache_1(active_cache_sha1) < 0)
+ die("unable to read index file");
+ active_cache_tree = read_cache_tree(active_cache_sha1);
+ dump_cache_tree(active_cache_tree, "");
+ return 0;
+}