git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/5] Add test-scrap-cache-tree

From
Thomas Rast <trast@student.ethz.ch>
Date
Dec 6, 2011, 17:43 UTC
Message-ID
<534454506f92428863de8fe0638f4129e962a073.1323191497.git.trast@student.ethz.ch>
In-Reply-To
<cover.1323191497.git.trast@student.ethz.ch>

A simple utility that invalidates all existing cache-tree data. We need this for tests. (We don't need a tool to rebuild the cache-tree data; git read-tree HEAD works for that.)

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 .gitignore              |    1 +
 Makefile                |    1 +
 test-scrap-cache-tree.c |   17 +++++++++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100644 test-scrap-cache-tree.c
diff --git a/.gitignore b/.gitignore
index 8572c8c..122336c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,6 +171,7 @@
 /test-date
 /test-delta
 /test-dump-cache-tree
+/test-scrap-cache-tree
 /test-genrandom
 /test-index-version
 /test-line-buffer
diff --git a/Makefile b/Makefile
index cbb5601..6bfa10b 100644
--- a/Makefile
+++ b/Makefile
@@ -436,6 +436,7 @@ TEST_PROGRAMS_NEED_X += test-ctype
 TEST_PROGRAMS_NEED_X += test-date
 TEST_PROGRAMS_NEED_X += test-delta
 TEST_PROGRAMS_NEED_X += test-dump-cache-tree
+TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
 TEST_PROGRAMS_NEED_X += test-genrandom
 TEST_PROGRAMS_NEED_X += test-index-version
 TEST_PROGRAMS_NEED_X += test-line-buffer
diff --git a/test-scrap-cache-tree.c b/test-scrap-cache-tree.c
new file mode 100644
index 0000000..4728013
--- /dev/null
+++ b/test-scrap-cache-tree.c
@@ -0,0 +1,17 @@
+#include "cache.h"
+#include "tree.h"
+#include "cache-tree.h"
+
+static struct lock_file index_lock;
+
+int main(int ac, char **av)
+{
+	int fd = hold_locked_index(&index_lock, 1);
+	if (read_cache() < 0)
+		die("unable to read index file");
+	active_cache_tree = NULL;
+	if (write_cache(fd, active_cache, active_nr)
+	    || commit_lock_file(&index_lock))
+		die("unable to write index file");
+	return 0;
+}
-- 
1.7.8.425.ga639d3
Previous: Thomas RastNext: Junio C Hamano
Message 2 of 10 in “cache-tree revisited”
  1. 0/5 cache-tree revisitedThomas Rast, Dec 6, 2011
  2. 1/5 Add test-scrap-cache-treeThomas Rast, Dec 6, 2011
  3. Junio C HamanoDec 6, 2011
  4. 2/5 Test the current state of the cache-tree optimizationThomas Rast, Dec 6, 2011
  5. 3/5 Refactor cache_tree_update idiom from commitThomas Rast, Dec 6, 2011
  6. 4/5 commit: write cache-tree data when writing index anywayThomas Rast, Dec 6, 2011
  7. 5/5 reset: update cache-tree data when appropriateThomas Rast, Dec 6, 2011
  8. Junio C HamanoDec 6, 2011
  9. Thomas RastDec 7, 2011
  10. Thomas RastDec 8, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.