@@ -1519,8 +1519,8 @@ static int run_apply(const struct am_state *state, const char *index_file)
15191519
15201520 if (index_file ) {
15211521 /* Reload index as apply_all_patches() will have modified it. */
1522- discard_cache ( );
1523- read_cache_from ( index_file );
1522+ discard_index ( & the_index );
1523+ read_index_from ( & the_index , index_file , get_git_dir () );
15241524 }
15251525
15261526 return 0 ;
@@ -1562,8 +1562,8 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15621562 if (build_fake_ancestor (state , index_path ))
15631563 return error ("could not build fake ancestor" );
15641564
1565- discard_cache ( );
1566- read_cache_from ( index_path );
1565+ discard_index ( & the_index );
1566+ read_index_from ( & the_index , index_path , get_git_dir () );
15671567
15681568 if (write_index_as_tree (& orig_tree , & the_index , index_path , 0 , NULL ))
15691569 return error (_ ("Repository lacks necessary blobs to fall back on 3-way merge." ));
@@ -1596,8 +1596,8 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15961596
15971597 say (state , stdout , _ ("Falling back to patching base and 3-way merge..." ));
15981598
1599- discard_cache ( );
1600- read_cache ( );
1599+ discard_index ( & the_index );
1600+ repo_read_index ( the_repository );
16011601
16021602 /*
16031603 * This is not so wrong. Depending on which base we picked, orig_tree
@@ -1781,7 +1781,8 @@ static void am_run(struct am_state *state, int resume)
17811781
17821782 unlink (am_path (state , "dirtyindex" ));
17831783
1784- if (refresh_and_write_cache (REFRESH_QUIET , 0 , 0 ) < 0 )
1784+ if (repo_refresh_and_write_index (the_repository , REFRESH_QUIET , 0 , 0 ,
1785+ NULL , NULL , NULL ) < 0 )
17851786 die (_ ("unable to write index file" ));
17861787
17871788 if (repo_index_has_changes (the_repository , NULL , & sb )) {
@@ -1930,7 +1931,7 @@ static void am_resolve(struct am_state *state, int allow_empty)
19301931 }
19311932 }
19321933
1933- if (unmerged_cache ( )) {
1934+ if (unmerged_index ( & the_index )) {
19341935 printf_ln (_ ("You still have unmerged paths in your index.\n"
19351936 "You should 'git add' each file with resolved conflicts to mark them as such.\n"
19361937 "You might run `git rm` on a file to accept \"deleted by them\" for it." ));
@@ -1967,9 +1968,9 @@ static int fast_forward_to(struct tree *head, struct tree *remote, int reset)
19671968 if (parse_tree (head ) || parse_tree (remote ))
19681969 return -1 ;
19691970
1970- hold_locked_index ( & lock_file , LOCK_DIE_ON_ERROR );
1971+ repo_hold_locked_index ( the_repository , & lock_file , LOCK_DIE_ON_ERROR );
19711972
1972- refresh_cache ( REFRESH_QUIET );
1973+ refresh_index ( & the_index , REFRESH_QUIET , NULL , NULL , NULL );
19731974
19741975 memset (& opts , 0 , sizeof (opts ));
19751976 opts .head_idx = 1 ;
@@ -2007,7 +2008,7 @@ static int merge_tree(struct tree *tree)
20072008 if (parse_tree (tree ))
20082009 return -1 ;
20092010
2010- hold_locked_index ( & lock_file , LOCK_DIE_ON_ERROR );
2011+ repo_hold_locked_index ( the_repository , & lock_file , LOCK_DIE_ON_ERROR );
20112012
20122013 memset (& opts , 0 , sizeof (opts ));
20132014 opts .head_idx = 1 ;
@@ -2045,7 +2046,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
20452046 if (!remote_tree )
20462047 return error (_ ("Could not parse object '%s'." ), oid_to_hex (remote ));
20472048
2048- read_cache_unmerged ( );
2049+ repo_read_index_unmerged ( the_repository );
20492050
20502051 if (fast_forward_to (head_tree , head_tree , 1 ))
20512052 return -1 ;
0 commit comments