@@ -3385,7 +3385,8 @@ static int verify_index_match(struct apply_state *state,
3385
3385
return -1 ;
3386
3386
return 0 ;
3387
3387
}
3388
- return ce_match_stat (ce , st , CE_MATCH_IGNORE_VALID |CE_MATCH_IGNORE_SKIP_WORKTREE );
3388
+ return ie_match_stat (state -> repo -> index , ce , st ,
3389
+ CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE );
3389
3390
}
3390
3391
3391
3392
#define SUBMODULE_PATCH_WITHOUT_INDEX 1
@@ -3518,14 +3519,14 @@ static int load_current(struct apply_state *state,
3518
3519
if (!patch -> is_new )
3519
3520
BUG ("patch to %s is not a creation" , patch -> old_name );
3520
3521
3521
- pos = cache_name_pos ( name , strlen (name ));
3522
+ pos = index_name_pos ( state -> repo -> index , name , strlen (name ));
3522
3523
if (pos < 0 )
3523
3524
return error (_ ("%s: does not exist in index" ), name );
3524
- ce = active_cache [pos ];
3525
+ ce = state -> repo -> index -> cache [pos ];
3525
3526
if (lstat (name , & st )) {
3526
3527
if (errno != ENOENT )
3527
3528
return error_errno ("%s" , name );
3528
- if (checkout_target (& the_index , ce , & st ))
3529
+ if (checkout_target (state -> repo -> index , ce , & st ))
3529
3530
return -1 ;
3530
3531
}
3531
3532
if (verify_index_match (state , ce , & st ))
@@ -3687,15 +3688,16 @@ static int check_preimage(struct apply_state *state,
3687
3688
}
3688
3689
3689
3690
if (state -> check_index && !previous ) {
3690
- int pos = cache_name_pos (old_name , strlen (old_name ));
3691
+ int pos = index_name_pos (state -> repo -> index , old_name ,
3692
+ strlen (old_name ));
3691
3693
if (pos < 0 ) {
3692
3694
if (patch -> is_new < 0 )
3693
3695
goto is_new ;
3694
3696
return error (_ ("%s: does not exist in index" ), old_name );
3695
3697
}
3696
- * ce = active_cache [pos ];
3698
+ * ce = state -> repo -> index -> cache [pos ];
3697
3699
if (stat_ret < 0 ) {
3698
- if (checkout_target (& the_index , * ce , st ))
3700
+ if (checkout_target (state -> repo -> index , * ce , st ))
3699
3701
return -1 ;
3700
3702
}
3701
3703
if (!state -> cached && verify_index_match (state , * ce , st ))
@@ -3742,7 +3744,7 @@ static int check_to_create(struct apply_state *state,
3742
3744
struct stat nst ;
3743
3745
3744
3746
if (state -> check_index &&
3745
- cache_name_pos ( new_name , strlen (new_name )) >= 0 &&
3747
+ index_name_pos ( state -> repo -> index , new_name , strlen (new_name )) >= 0 &&
3746
3748
!ok_if_exists )
3747
3749
return EXISTS_IN_INDEX ;
3748
3750
if (state -> cached )
@@ -3831,7 +3833,8 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *na
3831
3833
if (state -> check_index ) {
3832
3834
struct cache_entry * ce ;
3833
3835
3834
- ce = cache_file_exists (name -> buf , name -> len , ignore_case );
3836
+ ce = index_file_exists (state -> repo -> index , name -> buf ,
3837
+ name -> len , ignore_case );
3835
3838
if (ce && S_ISLNK (ce -> ce_mode ))
3836
3839
return 1 ;
3837
3840
} else {
@@ -4006,9 +4009,10 @@ static int check_patch_list(struct apply_state *state, struct patch *patch)
4006
4009
static int read_apply_cache (struct apply_state * state )
4007
4010
{
4008
4011
if (state -> index_file )
4009
- return read_cache_from (state -> index_file );
4012
+ return read_index_from (state -> repo -> index , state -> index_file ,
4013
+ get_git_dir ());
4010
4014
else
4011
- return read_cache ( );
4015
+ return read_index ( state -> repo -> index );
4012
4016
}
4013
4017
4014
4018
/* This function tries to read the object name from the current index */
@@ -4019,10 +4023,10 @@ static int get_current_oid(struct apply_state *state, const char *path,
4019
4023
4020
4024
if (read_apply_cache (state ) < 0 )
4021
4025
return -1 ;
4022
- pos = cache_name_pos ( path , strlen (path ));
4026
+ pos = index_name_pos ( state -> repo -> index , path , strlen (path ));
4023
4027
if (pos < 0 )
4024
4028
return -1 ;
4025
- oidcpy (oid , & active_cache [pos ]-> oid );
4029
+ oidcpy (oid , & state -> repo -> index -> cache [pos ]-> oid );
4026
4030
return 0 ;
4027
4031
}
4028
4032
@@ -4250,7 +4254,7 @@ static void patch_stats(struct apply_state *state, struct patch *patch)
4250
4254
static int remove_file (struct apply_state * state , struct patch * patch , int rmdir_empty )
4251
4255
{
4252
4256
if (state -> update_index && !state -> ita_only ) {
4253
- if (remove_file_from_cache ( patch -> old_name ) < 0 )
4257
+ if (remove_file_from_index ( state -> repo -> index , patch -> old_name ) < 0 )
4254
4258
return error (_ ("unable to remove %s from index" ), patch -> old_name );
4255
4259
}
4256
4260
if (!state -> cached ) {
@@ -4271,7 +4275,7 @@ static int add_index_file(struct apply_state *state,
4271
4275
struct cache_entry * ce ;
4272
4276
int namelen = strlen (path );
4273
4277
4274
- ce = make_empty_cache_entry (& the_index , namelen );
4278
+ ce = make_empty_cache_entry (state -> repo -> index , namelen );
4275
4279
memcpy (ce -> name , path , namelen );
4276
4280
ce -> ce_mode = create_ce_mode (mode );
4277
4281
ce -> ce_flags = create_ce_flags (0 );
@@ -4303,7 +4307,7 @@ static int add_index_file(struct apply_state *state,
4303
4307
"for newly created file %s" ), path );
4304
4308
}
4305
4309
}
4306
- if (add_cache_entry ( ce , ADD_CACHE_OK_TO_ADD ) < 0 ) {
4310
+ if (add_index_entry ( state -> repo -> index , ce , ADD_CACHE_OK_TO_ADD ) < 0 ) {
4307
4311
discard_cache_entry (ce );
4308
4312
return error (_ ("unable to add cache entry for %s" ), path );
4309
4313
}
@@ -4341,7 +4345,7 @@ static int try_create_file(struct apply_state *state, const char *path,
4341
4345
if (fd < 0 )
4342
4346
return 1 ;
4343
4347
4344
- if (convert_to_working_tree (& the_index , path , buf , size , & nbuf )) {
4348
+ if (convert_to_working_tree (state -> repo -> index , path , buf , size , & nbuf )) {
4345
4349
size = nbuf .len ;
4346
4350
buf = nbuf .buf ;
4347
4351
}
@@ -4438,17 +4442,17 @@ static int add_conflicted_stages_file(struct apply_state *state,
4438
4442
namelen = strlen (patch -> new_name );
4439
4443
mode = patch -> new_mode ? patch -> new_mode : (S_IFREG | 0644 );
4440
4444
4441
- remove_file_from_cache ( patch -> new_name );
4445
+ remove_file_from_index ( state -> repo -> index , patch -> new_name );
4442
4446
for (stage = 1 ; stage < 4 ; stage ++ ) {
4443
4447
if (is_null_oid (& patch -> threeway_stage [stage - 1 ]))
4444
4448
continue ;
4445
- ce = make_empty_cache_entry (& the_index , namelen );
4449
+ ce = make_empty_cache_entry (state -> repo -> index , namelen );
4446
4450
memcpy (ce -> name , patch -> new_name , namelen );
4447
4451
ce -> ce_mode = create_ce_mode (mode );
4448
4452
ce -> ce_flags = create_ce_flags (stage );
4449
4453
ce -> ce_namelen = namelen ;
4450
4454
oidcpy (& ce -> oid , & patch -> threeway_stage [stage - 1 ]);
4451
- if (add_cache_entry ( ce , ADD_CACHE_OK_TO_ADD ) < 0 ) {
4455
+ if (add_index_entry ( state -> repo -> index , ce , ADD_CACHE_OK_TO_ADD ) < 0 ) {
4452
4456
discard_cache_entry (ce );
4453
4457
return error (_ ("unable to add cache entry for %s" ),
4454
4458
patch -> new_name );
@@ -4897,7 +4901,7 @@ int apply_all_patches(struct apply_state *state,
4897
4901
}
4898
4902
4899
4903
if (state -> update_index ) {
4900
- res = write_locked_index (& the_index , & state -> lock_file , COMMIT_LOCK );
4904
+ res = write_locked_index (state -> repo -> index , & state -> lock_file , COMMIT_LOCK );
4901
4905
if (res ) {
4902
4906
error (_ ("Unable to write new index file" ));
4903
4907
res = -128 ;
0 commit comments