aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-04-25 00:45:12 +0200
committerJunio C Hamano <gitster@pobox.com>2012-05-03 13:15:09 -0700
commit9f2fb4a3737c86e245ce365f6ad8f901ad397d6f (patch)
treedc7e902c9bccffb0e5e75cd40448fc4eefc60ad4
parentf348ac923c9f834c3cdc434e6266872cf5710b71 (diff)
downloadgit-9f2fb4a3737c86e245ce365f6ad8f901ad397d6f.tar.gz
git-9f2fb4a3737c86e245ce365f6ad8f901ad397d6f.tar.xz
get_ref_dir(): take the containing directory as argument
Previously, the "dir" argument to get_ref_dir() was a pointer to the top-level ref_dir. Change the function to expect a pointer to the ref_dir corresponding to dirname. This allows entries to be added directly to dir, without having to recurse through the reference trie each time (i.e., we can use add_entry_to_dir() instead of add_ref()). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 9471b1d8a..afd0cf75b 100644
--- a/refs.c
+++ b/refs.c
@@ -765,7 +765,8 @@ void add_packed_ref(const char *refname, const unsigned char *sha1)
/*
* Read the loose references for refs from the namespace dirname.
- * dirname must end with '/'.
+ * dirname must end with '/'. dir must be the directory entry
+ * corresponding to dirname.
*/
static void get_ref_dir(struct ref_cache *refs, const char *dirname,
struct ref_dir *dir)
@@ -806,7 +807,8 @@ static void get_ref_dir(struct ref_cache *refs, const char *dirname,
; /* silently ignore */
} else if (S_ISDIR(st.st_mode)) {
strbuf_addch(&refname, '/');
- get_ref_dir(refs, refname.buf, dir);
+ get_ref_dir(refs, refname.buf,
+ &search_for_subdir(dir, refname.buf, 1)->u.subdir);
} else {
if (*refs->name) {
hashclr(sha1);
@@ -819,7 +821,8 @@ static void get_ref_dir(struct ref_cache *refs, const char *dirname,
hashclr(sha1);
flag |= REF_ISBROKEN;
}
- add_ref(dir, create_ref_entry(refname.buf, sha1, flag, 1));
+ add_entry_to_dir(dir,
+ create_ref_entry(refname.buf, sha1, flag, 1));
}
strbuf_setlen(&refname, dirnamelen);
}
@@ -830,7 +833,8 @@ static void get_ref_dir(struct ref_cache *refs, const char *dirname,
static struct ref_dir *get_loose_refs(struct ref_cache *refs)
{
if (!refs->did_loose) {
- get_ref_dir(refs, "refs/", &refs->loose);
+ get_ref_dir(refs, "refs/",
+ &search_for_subdir(&refs->loose, "refs/", 1)->u.subdir);
refs->did_loose = 1;
}
return &refs->loose;