55 * Based on git-commit.sh by Junio C Hamano and Linus Torvalds
66 */
77
8- #define USE_THE_INDEX_COMPATIBILITY_MACROS
8+ #define USE_THE_INDEX_VARIABLE
99#include "cache.h"
1010#include "config.h"
1111#include "lockfile.h"
@@ -414,7 +414,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
414414 discard_index (& the_index );
415415 read_index_from (& the_index , get_lock_file_path (& index_lock ),
416416 get_git_dir ());
417- if (update_main_cache_tree ( WRITE_TREE_SILENT ) == 0 ) {
417+ if (cache_tree_update ( & the_index , WRITE_TREE_SILENT ) == 0 ) {
418418 if (reopen_lock_file (& index_lock ) < 0 )
419419 die (_ ("unable to write index file" ));
420420 if (write_locked_index (& the_index , & index_lock , 0 ))
@@ -444,7 +444,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
444444 LOCK_DIE_ON_ERROR );
445445 add_files_to_cache (also ? prefix : NULL , & pathspec , 0 );
446446 refresh_cache_or_die (refresh_flags );
447- update_main_cache_tree ( WRITE_TREE_SILENT );
447+ cache_tree_update ( & the_index , WRITE_TREE_SILENT );
448448 if (write_locked_index (& the_index , & index_lock , 0 ))
449449 die (_ ("unable to write new_index file" ));
450450 commit_style = COMMIT_NORMAL ;
@@ -467,7 +467,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
467467 refresh_cache_or_die (refresh_flags );
468468 if (the_index .cache_changed
469469 || !cache_tree_fully_valid (the_index .cache_tree ))
470- update_main_cache_tree ( WRITE_TREE_SILENT );
470+ cache_tree_update ( & the_index , WRITE_TREE_SILENT );
471471 if (write_locked_index (& the_index , & index_lock ,
472472 COMMIT_LOCK | SKIP_IF_UNCHANGED ))
473473 die (_ ("unable to write new_index file" ));
@@ -516,7 +516,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
516516 repo_hold_locked_index (the_repository , & index_lock , LOCK_DIE_ON_ERROR );
517517 add_remove_files (& partial );
518518 refresh_index (& the_index , REFRESH_QUIET , NULL , NULL , NULL );
519- update_main_cache_tree ( WRITE_TREE_SILENT );
519+ cache_tree_update ( & the_index , WRITE_TREE_SILENT );
520520 if (write_locked_index (& the_index , & index_lock , 0 ))
521521 die (_ ("unable to write new_index file" ));
522522
@@ -991,9 +991,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
991991 struct object_id oid ;
992992 const char * parent = "HEAD" ;
993993
994- if (!active_nr ) {
995- discard_cache ( );
996- if (read_cache ( ) < 0 )
994+ if (!the_index . cache_nr ) {
995+ discard_index ( & the_index );
996+ if (repo_read_index ( the_repository ) < 0 )
997997 die (_ ("Cannot read index" ));
998998 }
999999
@@ -1079,7 +1079,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
10791079 }
10801080 read_index_from (& the_index , index_file , get_git_dir ());
10811081
1082- if (update_main_cache_tree ( 0 )) {
1082+ if (cache_tree_update ( & the_index , 0 )) {
10831083 error (_ ("Error building trees" ));
10841084 return 0 ;
10851085 }
0 commit comments