test-*-cache-tree: setup git dir

These test helper programs access the index, but do not ever setup_git_directory(), meaning we just blindly looked in ".git/index". This happened to work for the purposes of our tests (which do not run from subdirectories, nor in non-repos), but it's a bad habit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 20, 2016 at 02:16 UTC 4ce742fc9c09cd3b95be309bc093f8fa54c15f96
2 files changed +2
t/helper/test-dump-cache-tree.c
+1
@@ -58,6 +58,7 @@ int cmd_main(int ac, const char **av)
58 {
59 struct index_state istate;
60 struct cache_tree *another = cache_tree();
61 + setup_git_directory();
62 if (read_cache() < 0)
63 die("unable to read index file");
64 istate = the_index;
t/helper/test-scrap-cache-tree.c
+1
@@ -7,6 +7,7 @@ static struct lock_file index_lock;
7
8 int cmd_main(int ac, const char **av)
9 {
10 + setup_git_directory();
11 hold_locked_index(&index_lock, 1);
12 if (read_cache() < 0)
13 die("unable to read index file");