]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-*-cache-tree: setup git dir
authorJeff King <peff@peff.net>
Thu, 20 Oct 2016 06:16:59 +0000 (02:16 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 26 Oct 2016 20:30:51 +0000 (13:30 -0700)
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>
t/helper/test-dump-cache-tree.c
t/helper/test-scrap-cache-tree.c

index 44f3290258a003317e4aad4f90d17ce5529e3b07..7af116d49e04777b9321044e199254a2211aa4d4 100644 (file)
@@ -58,6 +58,7 @@ int cmd_main(int ac, const char **av)
 {
        struct index_state istate;
        struct cache_tree *another = cache_tree();
+       setup_git_directory();
        if (read_cache() < 0)
                die("unable to read index file");
        istate = the_index;
index 5b2fd0990894dd59a074ded5822bbcf215a989aa..27fe0405b887671ff0ca4cea1b258aa850e66c8c 100644 (file)
@@ -7,6 +7,7 @@ static struct lock_file index_lock;
 
 int cmd_main(int ac, const char **av)
 {
+       setup_git_directory();
        hold_locked_index(&index_lock, 1);
        if (read_cache() < 0)
                die("unable to read index file");