summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db4dd93)
raw | patch | inline | side by side (parent: db4dd93)
author | Michael Haggerty <mhagger@alum.mit.edu> | |
Fri, 12 Aug 2011 22:36:27 +0000 (00:36 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 14 Aug 2011 22:18:52 +0000 (15:18 -0700) |
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c | patch | blob | history |
index 10aebcc68908b36ad6d59dbd86c5c32f76399229..b325fc71fe473437e84513a91dd2eb7b057cdc6f 100644 (file)
--- a/refs.c
+++ b/refs.c
char did_packed;
struct ref_list *loose;
struct ref_list *packed;
-} cached_refs, submodule_refs;
+} *cached_refs, *submodule_refs;
static struct ref_list *current_ref;
static struct ref_list *extra_refs;
ca->did_loose = ca->did_packed = 0;
}
+struct cached_refs *create_cached_refs(void)
+{
+ struct cached_refs *refs;
+ refs = xmalloc(sizeof(struct cached_refs));
+ refs->did_loose = refs->did_packed = 0;
+ refs->loose = refs->packed = NULL;
+ return refs;
+}
+
/*
* Return a pointer to a cached_refs for the specified submodule. For
* the main repository, use submodule==NULL. The returned structure
*/
static struct cached_refs *get_cached_refs(const char *submodule)
{
- if (!submodule)
- return &cached_refs;
- else {
- /* For now, don't reuse the refs cache for submodules. */
- clear_cached_refs(&submodule_refs);
- return &submodule_refs;
+ if (!submodule) {
+ if (!cached_refs)
+ cached_refs = create_cached_refs();
+ return cached_refs;
+ } else {
+ if (!submodule_refs)
+ submodule_refs = create_cached_refs();
+ else
+ /* For now, don't reuse the refs cache for submodules. */
+ clear_cached_refs(submodule_refs);
+ return submodule_refs;
}
}