1
+ #define NO_THE_INDEX_COMPATIBILITY_MACROS
2
+
1
3
#include "cache.h"
2
4
#include "repository.h"
3
5
#include "config.h"
@@ -55,14 +57,15 @@ int is_gitmodules_unmerged(const struct index_state *istate)
55
57
* future version when we learn to stage the changes we do ourselves without
56
58
* staging any previous modifications.
57
59
*/
58
- int is_staging_gitmodules_ok (const struct index_state * istate )
60
+ int is_staging_gitmodules_ok (struct index_state * istate )
59
61
{
60
62
int pos = index_name_pos (istate , GITMODULES_FILE , strlen (GITMODULES_FILE ));
61
63
62
64
if ((pos >= 0 ) && (pos < istate -> cache_nr )) {
63
65
struct stat st ;
64
66
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 )
66
69
return 0 ;
67
70
}
68
71
@@ -143,9 +146,9 @@ int remove_path_from_gitmodules(const char *path)
143
146
return 0 ;
144
147
}
145
148
146
- void stage_updated_gitmodules (void )
149
+ void stage_updated_gitmodules (struct index_state * istate )
147
150
{
148
- if (add_file_to_cache ( GITMODULES_FILE , 0 ))
151
+ if (add_file_to_index ( istate , GITMODULES_FILE , 0 ))
149
152
die (_ ("staging updated .gitmodules failed" ));
150
153
}
151
154
@@ -1178,7 +1181,7 @@ int submodule_touches_in_range(struct object_id *excl_oid,
1178
1181
struct submodule_parallel_fetch {
1179
1182
int count ;
1180
1183
struct argv_array args ;
1181
- const char * work_tree ;
1184
+ struct repository * r ;
1182
1185
const char * prefix ;
1183
1186
int command_line_option ;
1184
1187
int default_option ;
@@ -1199,7 +1202,7 @@ static int get_fetch_recurse_config(const struct submodule *submodule,
1199
1202
1200
1203
int fetch_recurse = submodule -> fetch_recurse ;
1201
1204
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 )) {
1203
1206
fetch_recurse = parse_fetch_recurse_submodules_arg (key , value );
1204
1207
}
1205
1208
free (key );
@@ -1218,19 +1221,19 @@ static int get_next_submodule(struct child_process *cp,
1218
1221
int ret = 0 ;
1219
1222
struct submodule_parallel_fetch * spf = data ;
1220
1223
1221
- for (; spf -> count < active_nr ; spf -> count ++ ) {
1224
+ for (; spf -> count < spf -> r -> index -> cache_nr ; spf -> count ++ ) {
1222
1225
struct strbuf submodule_path = STRBUF_INIT ;
1223
1226
struct strbuf submodule_git_dir = STRBUF_INIT ;
1224
1227
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 ];
1226
1229
const char * git_dir , * default_argv ;
1227
1230
const struct submodule * submodule ;
1228
1231
struct submodule default_submodule = SUBMODULE_INIT ;
1229
1232
1230
1233
if (!S_ISGITLINK (ce -> ce_mode ))
1231
1234
continue ;
1232
1235
1233
- submodule = submodule_from_path ( & null_oid , ce -> name );
1236
+ submodule = submodule_from_cache ( spf -> r , & null_oid , ce -> name );
1234
1237
if (!submodule ) {
1235
1238
const char * name = default_name_or_path (ce -> name );
1236
1239
if (name ) {
@@ -1256,7 +1259,7 @@ static int get_next_submodule(struct child_process *cp,
1256
1259
continue ;
1257
1260
}
1258
1261
1259
- strbuf_addf (& submodule_path , "%s/%s" , spf -> work_tree , ce -> name );
1262
+ strbuf_repo_worktree_path (& submodule_path , spf -> r , "%s" , ce -> name );
1260
1263
strbuf_addf (& submodule_git_dir , "%s/.git" , submodule_path .buf );
1261
1264
strbuf_addf (& submodule_prefix , "%s%s/" , spf -> prefix , ce -> name );
1262
1265
git_dir = read_gitfile (submodule_git_dir .buf );
@@ -1309,24 +1312,25 @@ static int fetch_finish(int retvalue, struct strbuf *err,
1309
1312
return 0 ;
1310
1313
}
1311
1314
1312
- int fetch_populated_submodules (const struct argv_array * options ,
1315
+ int fetch_populated_submodules (struct repository * r ,
1316
+ const struct argv_array * options ,
1313
1317
const char * prefix , int command_line_option ,
1314
1318
int default_option ,
1315
1319
int quiet , int max_parallel_jobs )
1316
1320
{
1317
1321
int i ;
1318
1322
struct submodule_parallel_fetch spf = SPF_INIT ;
1319
1323
1320
- spf .work_tree = get_git_work_tree () ;
1324
+ spf .r = r ;
1321
1325
spf .command_line_option = command_line_option ;
1322
1326
spf .default_option = default_option ;
1323
1327
spf .quiet = quiet ;
1324
1328
spf .prefix = prefix ;
1325
1329
1326
- if (!spf . work_tree )
1330
+ if (!r -> worktree )
1327
1331
goto out ;
1328
1332
1329
- if (read_cache ( ) < 0 )
1333
+ if (repo_read_index ( r ) < 0 )
1330
1334
die ("index file corrupt" );
1331
1335
1332
1336
argv_array_push (& spf .args , "fetch" );
0 commit comments