5
5
*
6
6
*/
7
7
8
- #define USE_THE_REPOSITORY_VARIABLE
9
8
#define DISABLE_SIGN_COMPARE_WARNINGS
10
9
11
10
#include "builtin.h"
@@ -68,10 +67,10 @@ static void write_tempfile_record(const char *name, const char *prefix)
68
67
}
69
68
}
70
69
71
- static int checkout_file (const char * name , const char * prefix )
70
+ static int checkout_file (struct index_state * index , const char * name , const char * prefix )
72
71
{
73
72
int namelen = strlen (name );
74
- int pos = index_name_pos (the_repository -> index , name , namelen );
73
+ int pos = index_name_pos (index , name , namelen );
75
74
int has_same_name = 0 ;
76
75
int is_file = 0 ;
77
76
int is_skipped = 1 ;
@@ -81,8 +80,8 @@ static int checkout_file(const char *name, const char *prefix)
81
80
if (pos < 0 )
82
81
pos = - pos - 1 ;
83
82
84
- while (pos < the_repository -> index -> cache_nr ) {
85
- struct cache_entry * ce = the_repository -> index -> cache [pos ];
83
+ while (pos < index -> cache_nr ) {
84
+ struct cache_entry * ce = index -> cache [pos ];
86
85
if (ce_namelen (ce ) != namelen ||
87
86
memcmp (ce -> name , name , namelen ))
88
87
break ;
@@ -137,13 +136,13 @@ static int checkout_file(const char *name, const char *prefix)
137
136
return -1 ;
138
137
}
139
138
140
- static int checkout_all (const char * prefix , int prefix_length )
139
+ static int checkout_all (struct index_state * index , const char * prefix , int prefix_length )
141
140
{
142
141
int i , errs = 0 ;
143
142
struct cache_entry * last_ce = NULL ;
144
143
145
- for (i = 0 ; i < the_repository -> index -> cache_nr ; i ++ ) {
146
- struct cache_entry * ce = the_repository -> index -> cache [i ];
144
+ for (i = 0 ; i < index -> cache_nr ; i ++ ) {
145
+ struct cache_entry * ce = index -> cache [i ];
147
146
148
147
if (S_ISSPARSEDIR (ce -> ce_mode )) {
149
148
if (!ce_skip_worktree (ce ))
@@ -156,8 +155,8 @@ static int checkout_all(const char *prefix, int prefix_length)
156
155
* first entry inside the expanded sparse directory).
157
156
*/
158
157
if (ignore_skip_worktree ) {
159
- ensure_full_index (the_repository -> index );
160
- ce = the_repository -> index -> cache [i ];
158
+ ensure_full_index (index );
159
+ ce = index -> cache [i ];
161
160
}
162
161
}
163
162
@@ -213,7 +212,7 @@ static int option_parse_stage(const struct option *opt,
213
212
int cmd_checkout_index (int argc ,
214
213
const char * * argv ,
215
214
const char * prefix ,
216
- struct repository * repo UNUSED )
215
+ struct repository * repo )
217
216
{
218
217
int i ;
219
218
struct lock_file lock_file = LOCK_INIT ;
@@ -253,19 +252,19 @@ int cmd_checkout_index(int argc,
253
252
show_usage_with_options_if_asked (argc , argv ,
254
253
builtin_checkout_index_usage ,
255
254
builtin_checkout_index_options );
256
- git_config ( git_default_config , NULL );
255
+ repo_config ( repo , git_default_config , NULL );
257
256
prefix_length = prefix ? strlen (prefix ) : 0 ;
258
257
259
- prepare_repo_settings (the_repository );
260
- the_repository -> settings .command_requires_full_index = 0 ;
258
+ prepare_repo_settings (repo );
259
+ repo -> settings .command_requires_full_index = 0 ;
261
260
262
- if (repo_read_index (the_repository ) < 0 ) {
261
+ if (repo_read_index (repo ) < 0 ) {
263
262
die ("invalid cache" );
264
263
}
265
264
266
265
argc = parse_options (argc , argv , prefix , builtin_checkout_index_options ,
267
266
builtin_checkout_index_usage , 0 );
268
- state .istate = the_repository -> index ;
267
+ state .istate = repo -> index ;
269
268
state .force = force ;
270
269
state .quiet = quiet ;
271
270
state .not_new = not_new ;
@@ -285,8 +284,8 @@ int cmd_checkout_index(int argc,
285
284
*/
286
285
if (index_opt && !state .base_dir_len && !to_tempfile ) {
287
286
state .refresh_cache = 1 ;
288
- state .istate = the_repository -> index ;
289
- repo_hold_locked_index (the_repository , & lock_file ,
287
+ state .istate = repo -> index ;
288
+ repo_hold_locked_index (repo , & lock_file ,
290
289
LOCK_DIE_ON_ERROR );
291
290
}
292
291
@@ -304,7 +303,7 @@ int cmd_checkout_index(int argc,
304
303
if (read_from_stdin )
305
304
die ("git checkout-index: don't mix '--stdin' and explicit filenames" );
306
305
p = prefix_path (prefix , prefix_length , arg );
307
- err |= checkout_file (p , prefix );
306
+ err |= checkout_file (repo -> index , p , prefix );
308
307
free (p );
309
308
}
310
309
@@ -326,15 +325,15 @@ int cmd_checkout_index(int argc,
326
325
strbuf_swap (& buf , & unquoted );
327
326
}
328
327
p = prefix_path (prefix , prefix_length , buf .buf );
329
- err |= checkout_file (p , prefix );
328
+ err |= checkout_file (repo -> index , p , prefix );
330
329
free (p );
331
330
}
332
331
strbuf_release (& unquoted );
333
332
strbuf_release (& buf );
334
333
}
335
334
336
335
if (all )
337
- err |= checkout_all (prefix , prefix_length );
336
+ err |= checkout_all (repo -> index , prefix , prefix_length );
338
337
339
338
if (pc_workers > 1 )
340
339
err |= run_parallel_checkout (& state , pc_workers , pc_threshold ,
@@ -344,7 +343,7 @@ int cmd_checkout_index(int argc,
344
343
return 1 ;
345
344
346
345
if (is_lock_file_locked (& lock_file ) &&
347
- write_locked_index (the_repository -> index , & lock_file , COMMIT_LOCK ))
346
+ write_locked_index (repo -> index , & lock_file , COMMIT_LOCK ))
348
347
die ("Unable to write new index file" );
349
348
return 0 ;
350
349
}
0 commit comments