* [PATCH 17/19] temporarily change add_cache_entry to create an empty cache on demand
@ 2005-04-21 18:38 Brad Roberts
0 siblings, 0 replies; only message in thread
From: Brad Roberts @ 2005-04-21 18:38 UTC (permalink / raw)
To: git
tree 6feaeb314fb1bea393250972b109b7d218cf37d7
parent b965055600b8bf4927ea631446cd6cde714aef95
author Brad Roberts <braddr@puremagic.com> 1114087949 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114087949 -0700
[PATCH] temporarily change add_cache_entry to create an empty cache on demand
read-tree.c expects to be able to add entries into an empty cache in the
non-merging mode.
Signed-off-by: Brad Roberts <braddr@puremagic.com>
---
read-cache.c | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
Index: read-cache.c
===================================================================
--- b965055600b8bf4927ea631446cd6cde714aef95:1/read-cache.c (mode:100644 sha1:c399f8e497441147afe630ca080558a8c6c79c78)
+++ 058c25fd81e5949354d96f2aad222ae73a6c1dee:1/read-cache.c (mode:100644 sha1:31e293a3686622c9ec180d41aa37d85ce49325e8)
@@ -32,6 +32,18 @@
static struct cache * cache = NULL;
+struct cache * new_cache()
+{
+ return (struct cache*)calloc(1, sizeof(struct cache));
+}
+
+void free_cache()
+{
+ munmap(cache->map.ptr, cache->map.size);
+ free(cache);
+ cache = NULL;
+}
+
int cache_match_stat(struct cache_entry *ce, struct stat *st)
{
unsigned int changed = 0;
@@ -155,6 +167,11 @@
{
int pos;
+ /* temporary, read-tree.c expects the cache to always exist, even
+ * without a read_cache being called */
+ if (!cache)
+ cache = new_cache();
+
pos = cache_name_pos(ce->name, htons(ce->ce_flags));
/* existing match? Just replace it */
@@ -230,7 +247,7 @@
return (errno == ENOENT) ? 0 : error("open failed");
errno = ENOMEM;
- cache = (struct cache*)malloc(sizeof(struct cache));
+ cache = new_cache();
if (!cache)
return error("unable to allocate cache");
@@ -333,10 +350,3 @@
}
return ce_flush(&c, newfd);
}
-
-void free_cache()
-{
- munmap(cache->map.ptr, cache->map.size);
- free(cache);
- cache = NULL;
-}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-04-21 18:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-21 18:38 [PATCH 17/19] temporarily change add_cache_entry to create an empty cache on demand Brad Roberts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).