316
struct tree_desc t;
317
318
if (!current_head) {
319
- discard_cache();
319
+ discard_index(&the_index);
320
return;
321
}
322
343
* refresh_flags contains REFRESH_QUIET, so the only errors
344
* are for unmerged entries.
345
*/
346
- if (refresh_cache(refresh_flags | REFRESH_IN_PORCELAIN))
346
+ if (refresh_index(&the_index, refresh_flags | REFRESH_IN_PORCELAIN, NULL, NULL, NULL))
347
die_resolve_conflict("commit");
348
}
349
382
(!amend || (fixup_message && strcmp(fixup_prefix, "amend"))))))
383
die(_("No paths with --include/--only does not make sense."));
384
385
- if (read_cache_preload(&pathspec) < 0)
385
+ if (repo_read_index_preload(the_repository, &pathspec, 0) < 0)
386
die(_("index file corrupt"));
387
388
if (interactive) {
389
char *old_index_env = NULL, *old_repo_index_file;
390
- hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
390
+ repo_hold_locked_index(the_repository, &index_lock,
391
+ LOCK_DIE_ON_ERROR);
392
393
refresh_cache_or_die(refresh_flags);
394
411
unsetenv(INDEX_ENVIRONMENT);
412
FREE_AND_NULL(old_index_env);
413
413
- discard_cache();
414
- read_cache_from(get_lock_file_path(&index_lock));
414
+ discard_index(&the_index);
415
+ read_index_from(&the_index, get_lock_file_path(&index_lock),
416
+ get_git_dir());
417
if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
418
if (reopen_lock_file(&index_lock) < 0)
419
die(_("unable to write index file"));
440
* (B) on failure, rollback the real index.
441
*/
442
if (all || (also && pathspec.nr)) {
441
- hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
443
+ repo_hold_locked_index(the_repository, &index_lock,
444
+ LOCK_DIE_ON_ERROR);
445
add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
446
refresh_cache_or_die(refresh_flags);
447
update_main_cache_tree(WRITE_TREE_SILENT);
462
* We still need to refresh the index here.
463
*/
464
if (!only && !pathspec.nr) {
462
- hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
465
+ repo_hold_locked_index(the_repository, &index_lock,
466
+ LOCK_DIE_ON_ERROR);
467
refresh_cache_or_die(refresh_flags);
468
if (the_index.cache_changed
469
|| !cache_tree_fully_valid(the_index.cache_tree))
509
if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec))
510
exit(1);
511
508
- discard_cache();
509
- if (read_cache() < 0)
512
+ discard_index(&the_index);
513
+ if (repo_read_index(the_repository) < 0)
514
die(_("cannot read the index"));
515
512
- hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
516
+ repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR);
517
add_remove_files(&partial);
514
- refresh_cache(REFRESH_QUIET);
518
+ refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
519
update_main_cache_tree(WRITE_TREE_SILENT);
520
if (write_locked_index(&the_index, &index_lock, 0))
521
die(_("unable to write new_index file"));
527
528
create_base_index(current_head);
529
add_remove_files(&partial);
526
- refresh_cache(REFRESH_QUIET);
530
+ refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL);
531
532
if (write_locked_index(&the_index, &false_lock, 0))
533
die(_("unable to write temporary index file"));
534
531
- discard_cache();
535
+ discard_index(&the_index);
536
ret = get_lock_file_path(&false_lock);
533
- read_cache_from(ret);
537
+ read_index_from(&the_index, ret, get_git_dir());
538
out:
539
string_list_clear(&partial, 0);
540
clear_pathspec(&pathspec);
1072
* and could have updated it. We must do this before we invoke
1073
* the editor and after we invoke run_status above.
1074
*/
1071
- discard_cache();
1075
+ discard_index(&the_index);
1076
}
1073
- read_cache_from(index_file);
1077
+ read_index_from(&the_index, index_file, get_git_dir());
1078
1079
if (update_main_cache_tree(0)) {
1080
error(_("Error building trees"));
1560
&s.pathspec, NULL, NULL);
1561
1562
if (use_optional_locks())
1559
- fd = hold_locked_index(&index_lock, 0);
1563
+ fd = repo_hold_locked_index(the_repository, &index_lock, 0);
1564
else
1565
fd = -1;
1566