-static const char *current_index_file = NULL;
-static const char *original_index_file;
-static const char *temporary_index_file;
-static int cache_dirty = 0;
-
-static int flush_cache(void)
-{
- /* flush temporary index */
- struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
- int fd = hold_lock_file_for_update(lock, current_index_file, 1);
- if (write_cache(fd, active_cache, active_nr) ||
- close(fd) || commit_lock_file(lock))
- die ("unable to write %s", current_index_file);
- discard_cache();
- cache_dirty = 0;
- return 0;
-}
-
-static void setup_index(int temp)
-{
- current_index_file = temp ? temporary_index_file: original_index_file;
- if (cache_dirty) {
- discard_cache();
- cache_dirty = 0;
- }
- unlink(temporary_index_file);
- discard_cache();
-}
-