1+ #define NO_THE_INDEX_COMPATIBILITY_MACROS
2+
13#include "cache.h"
24#include "repository.h"
35#include "config.h"
@@ -55,14 +57,15 @@ int is_gitmodules_unmerged(const struct index_state *istate)
5557 * future version when we learn to stage the changes we do ourselves without
5658 * staging any previous modifications.
5759 */
58- int is_staging_gitmodules_ok (const struct index_state * istate )
60+ int is_staging_gitmodules_ok (struct index_state * istate )
5961{
6062 int pos = index_name_pos (istate , GITMODULES_FILE , strlen (GITMODULES_FILE ));
6163
6264 if ((pos >= 0 ) && (pos < istate -> cache_nr )) {
6365 struct stat st ;
6466 if (lstat (GITMODULES_FILE , & st ) == 0 &&
65- ce_match_stat (istate -> cache [pos ], & st , CE_MATCH_IGNORE_FSMONITOR ) & DATA_CHANGED )
67+ ie_match_stat (istate , istate -> cache [pos ], & st ,
68+ CE_MATCH_IGNORE_FSMONITOR ) & DATA_CHANGED )
6669 return 0 ;
6770 }
6871
@@ -143,9 +146,9 @@ int remove_path_from_gitmodules(const char *path)
143146 return 0 ;
144147}
145148
146- void stage_updated_gitmodules (void )
149+ void stage_updated_gitmodules (struct index_state * istate )
147150{
148- if (add_file_to_cache ( GITMODULES_FILE , 0 ))
151+ if (add_file_to_index ( istate , GITMODULES_FILE , 0 ))
149152 die (_ ("staging updated .gitmodules failed" ));
150153}
151154
@@ -1178,7 +1181,7 @@ int submodule_touches_in_range(struct object_id *excl_oid,
11781181struct submodule_parallel_fetch {
11791182 int count ;
11801183 struct argv_array args ;
1181- const char * work_tree ;
1184+ struct repository * r ;
11821185 const char * prefix ;
11831186 int command_line_option ;
11841187 int default_option ;
@@ -1199,7 +1202,7 @@ static int get_fetch_recurse_config(const struct submodule *submodule,
11991202
12001203 int fetch_recurse = submodule -> fetch_recurse ;
12011204 key = xstrfmt ("submodule.%s.fetchRecurseSubmodules" , submodule -> name );
1202- if (!repo_config_get_string_const (the_repository , key , & value )) {
1205+ if (!repo_config_get_string_const (spf -> r , key , & value )) {
12031206 fetch_recurse = parse_fetch_recurse_submodules_arg (key , value );
12041207 }
12051208 free (key );
@@ -1218,19 +1221,19 @@ static int get_next_submodule(struct child_process *cp,
12181221 int ret = 0 ;
12191222 struct submodule_parallel_fetch * spf = data ;
12201223
1221- for (; spf -> count < active_nr ; spf -> count ++ ) {
1224+ for (; spf -> count < spf -> r -> index -> cache_nr ; spf -> count ++ ) {
12221225 struct strbuf submodule_path = STRBUF_INIT ;
12231226 struct strbuf submodule_git_dir = STRBUF_INIT ;
12241227 struct strbuf submodule_prefix = STRBUF_INIT ;
1225- const struct cache_entry * ce = active_cache [spf -> count ];
1228+ const struct cache_entry * ce = spf -> r -> index -> cache [spf -> count ];
12261229 const char * git_dir , * default_argv ;
12271230 const struct submodule * submodule ;
12281231 struct submodule default_submodule = SUBMODULE_INIT ;
12291232
12301233 if (!S_ISGITLINK (ce -> ce_mode ))
12311234 continue ;
12321235
1233- submodule = submodule_from_path ( & null_oid , ce -> name );
1236+ submodule = submodule_from_cache ( spf -> r , & null_oid , ce -> name );
12341237 if (!submodule ) {
12351238 const char * name = default_name_or_path (ce -> name );
12361239 if (name ) {
@@ -1256,7 +1259,7 @@ static int get_next_submodule(struct child_process *cp,
12561259 continue ;
12571260 }
12581261
1259- strbuf_addf (& submodule_path , "%s/%s" , spf -> work_tree , ce -> name );
1262+ strbuf_repo_worktree_path (& submodule_path , spf -> r , "%s" , ce -> name );
12601263 strbuf_addf (& submodule_git_dir , "%s/.git" , submodule_path .buf );
12611264 strbuf_addf (& submodule_prefix , "%s%s/" , spf -> prefix , ce -> name );
12621265 git_dir = read_gitfile (submodule_git_dir .buf );
@@ -1309,24 +1312,25 @@ static int fetch_finish(int retvalue, struct strbuf *err,
13091312 return 0 ;
13101313}
13111314
1312- int fetch_populated_submodules (const struct argv_array * options ,
1315+ int fetch_populated_submodules (struct repository * r ,
1316+ const struct argv_array * options ,
13131317 const char * prefix , int command_line_option ,
13141318 int default_option ,
13151319 int quiet , int max_parallel_jobs )
13161320{
13171321 int i ;
13181322 struct submodule_parallel_fetch spf = SPF_INIT ;
13191323
1320- spf .work_tree = get_git_work_tree () ;
1324+ spf .r = r ;
13211325 spf .command_line_option = command_line_option ;
13221326 spf .default_option = default_option ;
13231327 spf .quiet = quiet ;
13241328 spf .prefix = prefix ;
13251329
1326- if (!spf . work_tree )
1330+ if (!r -> worktree )
13271331 goto out ;
13281332
1329- if (read_cache ( ) < 0 )
1333+ if (repo_read_index ( r ) < 0 )
13301334 die ("index file corrupt" );
13311335
13321336 argv_array_push (& spf .args , "fetch" );
0 commit comments