From: Brad Roberts <braddr@gameboy2.puremagic.com>
To: git@vger.kernel.org
Subject: [PATCH 17/19] temporarily change add_cache_entry to create an empty cache on demand
Date: Thu, 21 Apr 2005 11:38:51 -0700 [thread overview]
Message-ID: <200504211838.j3LIcpuC027819@gameboy2.puremagic.com> (raw)
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;
-}
reply other threads:[~2005-04-21 18:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200504211838.j3LIcpuC027819@gameboy2.puremagic.com \
--to=braddr@gameboy2.puremagic.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).