Skip to content

Commit 1aed2fe

Browse files
trastgitster
authored andcommitted
Add test-scrap-cache-tree
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 406da78 commit 1aed2fe

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
/test-date
172172
/test-delta
173173
/test-dump-cache-tree
174+
/test-scrap-cache-tree
174175
/test-genrandom
175176
/test-index-version
176177
/test-line-buffer

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ TEST_PROGRAMS_NEED_X += test-ctype
435435
TEST_PROGRAMS_NEED_X += test-date
436436
TEST_PROGRAMS_NEED_X += test-delta
437437
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
438+
TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
438439
TEST_PROGRAMS_NEED_X += test-genrandom
439440
TEST_PROGRAMS_NEED_X += test-index-version
440441
TEST_PROGRAMS_NEED_X += test-line-buffer

test-scrap-cache-tree.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "cache.h"
2+
#include "tree.h"
3+
#include "cache-tree.h"
4+
5+
static struct lock_file index_lock;
6+
7+
int main(int ac, char **av)
8+
{
9+
int fd = hold_locked_index(&index_lock, 1);
10+
if (read_cache() < 0)
11+
die("unable to read index file");
12+
active_cache_tree = NULL;
13+
if (write_cache(fd, active_cache, active_nr)
14+
|| commit_lock_file(&index_lock))
15+
die("unable to write index file");
16+
return 0;
17+
}

0 commit comments

Comments
 (0)