]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sparse-index.c
environment.h: move declarations for environment.c functions from cache.h
[thirdparty/git.git] / sparse-index.c
index 8c269dab803fa9a06a0e31ff42b6a20ec1983dbc..886054729e5e343f664d81da5c5ad6b48cf06e8a 100644 (file)
@@ -1,4 +1,7 @@
 #include "cache.h"
+#include "alloc.h"
+#include "environment.h"
+#include "gettext.h"
 #include "repository.h"
 #include "sparse-index.h"
 #include "tree.h"
@@ -128,9 +131,6 @@ int is_sparse_index_allowed(struct index_state *istate, int flags)
        if (!core_apply_sparse_checkout || !core_sparse_checkout_cone)
                return 0;
 
-       if (!istate->repo)
-               istate->repo = the_repository;
-
        if (!(flags & SPARSE_INDEX_MEMORY_ONLY)) {
                int test_env;
 
@@ -299,7 +299,7 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
         * If the index is already full, then keep it full. We will convert
         * it to a sparse index on write, if possible.
         */
-       if (!istate || istate->sparse_index == INDEX_EXPANDED)
+       if (istate->sparse_index == INDEX_EXPANDED)
                return;
 
        /*
@@ -327,9 +327,6 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
                        pl = NULL;
        }
 
-       if (!istate->repo)
-               istate->repo = the_repository;
-
        /*
         * A NULL pattern set indicates we are expanding a full index, so
         * we use a special region name that indicates the full expansion.
@@ -424,6 +421,8 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
 
 void ensure_full_index(struct index_state *istate)
 {
+       if (!istate)
+               BUG("ensure_full_index() must get an index!");
        expand_index(istate, NULL);
 }
 
@@ -547,12 +546,9 @@ void expand_to_path(struct index_state *istate,
        if (in_expand_to_path)
                return;
 
-       if (!istate || !istate->sparse_index)
+       if (!istate->sparse_index)
                return;
 
-       if (!istate->repo)
-               istate->repo = the_repository;
-
        in_expand_to_path = 1;
 
        /*