55 *
66 */
77
8+ #define USE_THE_REPOSITORY_VARIABLE
89#define DISABLE_SIGN_COMPARE_WARNINGS
910
1011#include "builtin.h"
@@ -67,10 +68,10 @@ static void write_tempfile_record(const char *name, const char *prefix)
6768 }
6869}
6970
70- static int checkout_file (struct repository * repo , const char * name , const char * prefix )
71+ static int checkout_file (const char * name , const char * prefix )
7172{
7273 int namelen = strlen (name );
73- int pos = index_name_pos (repo -> index , name , namelen );
74+ int pos = index_name_pos (the_repository -> index , name , namelen );
7475 int has_same_name = 0 ;
7576 int is_file = 0 ;
7677 int is_skipped = 1 ;
@@ -80,8 +81,8 @@ static int checkout_file(struct repository *repo, const char *name, const char *
8081 if (pos < 0 )
8182 pos = - pos - 1 ;
8283
83- while (pos < repo -> index -> cache_nr ) {
84- struct cache_entry * ce = repo -> index -> cache [pos ];
84+ while (pos < the_repository -> index -> cache_nr ) {
85+ struct cache_entry * ce = the_repository -> index -> cache [pos ];
8586 if (ce_namelen (ce ) != namelen ||
8687 memcmp (ce -> name , name , namelen ))
8788 break ;
@@ -136,13 +137,13 @@ static int checkout_file(struct repository *repo, const char *name, const char *
136137 return -1 ;
137138}
138139
139- static int checkout_all (struct repository * repo , const char * prefix , int prefix_length )
140+ static int checkout_all (const char * prefix , int prefix_length )
140141{
141142 int i , errs = 0 ;
142143 struct cache_entry * last_ce = NULL ;
143144
144- for (i = 0 ; i < repo -> index -> cache_nr ; i ++ ) {
145- struct cache_entry * ce = repo -> index -> cache [i ];
145+ for (i = 0 ; i < the_repository -> index -> cache_nr ; i ++ ) {
146+ struct cache_entry * ce = the_repository -> index -> cache [i ];
146147
147148 if (S_ISSPARSEDIR (ce -> ce_mode )) {
148149 if (!ce_skip_worktree (ce ))
@@ -155,8 +156,8 @@ static int checkout_all(struct repository *repo, const char *prefix, int prefix_
155156 * first entry inside the expanded sparse directory).
156157 */
157158 if (ignore_skip_worktree ) {
158- ensure_full_index (repo -> index );
159- ce = repo -> index -> cache [i ];
159+ ensure_full_index (the_repository -> index );
160+ ce = the_repository -> index -> cache [i ];
160161 }
161162 }
162163
@@ -212,7 +213,7 @@ static int option_parse_stage(const struct option *opt,
212213int cmd_checkout_index (int argc ,
213214 const char * * argv ,
214215 const char * prefix ,
215- struct repository * repo )
216+ struct repository * repo UNUSED )
216217{
217218 int i ;
218219 struct lock_file lock_file = LOCK_INIT ;
@@ -252,19 +253,19 @@ int cmd_checkout_index(int argc,
252253 show_usage_with_options_if_asked (argc , argv ,
253254 builtin_checkout_index_usage ,
254255 builtin_checkout_index_options );
255- repo_config ( repo , git_default_config , NULL );
256+ git_config ( git_default_config , NULL );
256257 prefix_length = prefix ? strlen (prefix ) : 0 ;
257258
258- prepare_repo_settings (repo );
259- repo -> settings .command_requires_full_index = 0 ;
259+ prepare_repo_settings (the_repository );
260+ the_repository -> settings .command_requires_full_index = 0 ;
260261
261- if (repo_read_index (repo ) < 0 ) {
262+ if (repo_read_index (the_repository ) < 0 ) {
262263 die ("invalid cache" );
263264 }
264265
265266 argc = parse_options (argc , argv , prefix , builtin_checkout_index_options ,
266267 builtin_checkout_index_usage , 0 );
267- state .istate = repo -> index ;
268+ state .istate = the_repository -> index ;
268269 state .force = force ;
269270 state .quiet = quiet ;
270271 state .not_new = not_new ;
@@ -284,8 +285,8 @@ int cmd_checkout_index(int argc,
284285 */
285286 if (index_opt && !state .base_dir_len && !to_tempfile ) {
286287 state .refresh_cache = 1 ;
287- state .istate = repo -> index ;
288- repo_hold_locked_index (repo , & lock_file ,
288+ state .istate = the_repository -> index ;
289+ repo_hold_locked_index (the_repository , & lock_file ,
289290 LOCK_DIE_ON_ERROR );
290291 }
291292
@@ -303,7 +304,7 @@ int cmd_checkout_index(int argc,
303304 if (read_from_stdin )
304305 die ("git checkout-index: don't mix '--stdin' and explicit filenames" );
305306 p = prefix_path (prefix , prefix_length , arg );
306- err |= checkout_file (repo , p , prefix );
307+ err |= checkout_file (p , prefix );
307308 free (p );
308309 }
309310
@@ -325,15 +326,15 @@ int cmd_checkout_index(int argc,
325326 strbuf_swap (& buf , & unquoted );
326327 }
327328 p = prefix_path (prefix , prefix_length , buf .buf );
328- err |= checkout_file (repo , p , prefix );
329+ err |= checkout_file (p , prefix );
329330 free (p );
330331 }
331332 strbuf_release (& unquoted );
332333 strbuf_release (& buf );
333334 }
334335
335336 if (all )
336- err |= checkout_all (repo , prefix , prefix_length );
337+ err |= checkout_all (prefix , prefix_length );
337338
338339 if (pc_workers > 1 )
339340 err |= run_parallel_checkout (& state , pc_workers , pc_threshold ,
@@ -343,7 +344,7 @@ int cmd_checkout_index(int argc,
343344 return 1 ;
344345
345346 if (is_lock_file_locked (& lock_file ) &&
346- write_locked_index (repo -> index , & lock_file , COMMIT_LOCK ))
347+ write_locked_index (the_repository -> index , & lock_file , COMMIT_LOCK ))
347348 die ("Unable to write new index file" );
348349 return 0 ;
349350}
0 commit comments