summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-11-16 17:35:47 -0800
committerJunio C Hamano <gitster@pobox.com>2016-11-16 17:38:25 -0800
commitcdeb4042e35b108e254795cd134d5039e772a4e3 (patch)
treea296ecc15a39f030c566a7587c86ae75b90de029 /cache.h
parent0b65a8dbdb38962e700ee16776a3042beb489060 (diff)
downloadgit-jc/cache-tree-freshen.tar.gz
cache-tree: make sure to "touch" tree objects the cache-tree recordsjc/cache-tree-freshen
The cache_tree_fully_valid() function is called by callers that want to know if they need to call cache_tree_update(), i.e. as an attempt to optimize. They all want to have a fully valid cache-tree in the end so that they can write a tree object out. We used to check if the cached tree object is up-to-date (i.e. the index entires covered by the cache-tree entry hasn't been changed since the roll-up hash was computed for the cache-tree entry) and made sure the tree object is already in the object store. Since the top-level tree we would soon be asked to write out (and would find in the object store) may not be anchored to any refs or commits immediately, freshen the tree object when it happens. Similarly, when we actually compute the cache-tree entries in cache_tree_update(), we refrained from writing a tree object out when it already exists in the object store. We would want to freshen the tree object in that case to protect it from premature pruning. Strictly speaking, freshing these tree objects at each and every level is probably unnecessary, given that anything reachable from a young object inherits the youth from the referring object to be protected from pruning. It should be sufficient to freshen only the very top-level tree instead. Benchmarking and optimization is left as an exercise for later days. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 4ff196c259..72c0b321ac 100644
--- a/cache.h
+++ b/cache.h
@@ -1077,6 +1077,7 @@ extern int sha1_object_info(const unsigned char *, unsigned long *);
extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);
+extern int freshen_object(const unsigned char *);
extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
extern int force_object_loose(const unsigned char *sha1, time_t mtime);
extern int git_open_noatime(const char *name);