summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index c0b031367b..c375e912a9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -836,6 +836,23 @@ unmap:
die("index file corrupt");
}
+int discard_cache()
+{
+ int ret;
+
+ if (cache_mmap == NULL)
+ return 0;
+ ret = munmap(cache_mmap, cache_mmap_size);
+ cache_mmap = NULL;
+ cache_mmap_size = 0;
+ active_nr = active_cache_changed = 0;
+ index_file_timestamp = 0;
+ cache_tree_free(&active_cache_tree);
+
+ /* no need to throw away allocated active_cache */
+ return ret;
+}
+
#define WRITE_BUFFER_SIZE 8192
static unsigned char write_buffer[WRITE_BUFFER_SIZE];
static unsigned long write_buffer_len;