From: Michael Haggerty <mhagger@xxxxxxxxxxxx> This means that it contains enough information to serve as the sole argument to get_ref_dir(), which will be changed in the next commit. Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx> --- refs.c | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/refs.c b/refs.c index 4a3546b..4088167 100644 --- a/refs.c +++ b/refs.c @@ -106,6 +106,8 @@ struct ref_value { unsigned char peeled[20]; }; +struct ref_cache; + struct ref_dir { int nr, alloc; @@ -113,6 +115,12 @@ struct ref_dir { int sorted; struct ref_entry **entries; + + /* + * A pointer to the ref_cache that contains this ref_dir, or + * NULL if this ref_dir is used for extra_refs. + */ + struct ref_cache *ref_cache; }; /* ISSYMREF=0x01, ISPACKED=0x02, and ISBROKEN=0x04 are public interfaces */ @@ -226,13 +234,15 @@ static void clear_ref_dir(struct ref_dir *dir) * dirname is the name of the directory with a trailing slash (e.g., * "refs/heads/") or "" for the top-level directory. */ -static struct ref_entry *create_dir_entry(const char *dirname) +static struct ref_entry *create_dir_entry(struct ref_cache *ref_cache, + const char *dirname) { struct ref_entry *direntry; int len = strlen(dirname); direntry = xcalloc(1, sizeof(struct ref_entry) + len + 1); memcpy(direntry->name, dirname, len + 1); direntry->flag = REF_DIR; + direntry->u.subdir.ref_cache = ref_cache; return direntry; } @@ -312,7 +322,8 @@ static struct ref_entry *find_containing_direntry(struct ref_entry *direntry, direntry = NULL; break; } - entry = create_dir_entry(refname_copy); + entry = create_dir_entry(direntry->u.subdir.ref_cache, + refname_copy); add_entry(direntry, entry); } slash[1] = tmp; @@ -726,7 +737,7 @@ static void read_packed_refs(FILE *f, struct ref_entry *direntry) void add_extra_ref(const char *refname, const unsigned char *sha1, int flag) { if (!extra_refs) - extra_refs = create_dir_entry(""); + extra_refs = create_dir_entry(NULL, ""); add_ref(extra_refs, create_ref_entry(refname, sha1, flag, 0)); } @@ -744,7 +755,7 @@ static struct ref_entry *get_packed_refs(struct ref_cache *refs) const char *packed_refs_file; FILE *f; - refs->packed = create_dir_entry(""); + refs->packed = create_dir_entry(refs, ""); if (*refs->name) packed_refs_file = git_path_submodule(refs->name, "packed-refs"); else @@ -835,7 +846,7 @@ static void get_ref_dir(struct ref_cache *refs, const char *dirname) static struct ref_entry *get_loose_refs(struct ref_cache *refs) { if (!refs->loose) { - refs->loose = create_dir_entry(""); + refs->loose = create_dir_entry(refs, ""); get_ref_dir(refs, "refs/"); } return refs->loose; -- 1.7.8 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html