OSDN Git Service

get_loose_ref_cache(): new function
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 16 Apr 2017 06:41:38 +0000 (08:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Apr 2017 04:32:46 +0000 (21:32 -0700)
Extract a new function, `get_loose_ref_cache()`, from
get_loose_ref_dir(). The function returns the `ref_cache` for the
loose refs of a `files_ref_store`.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c

index 3beab0b..7ae7c6a 100644 (file)
@@ -524,7 +524,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
        }
 }
 
-static struct ref_dir *get_loose_ref_dir(struct files_ref_store *refs)
+static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs)
 {
        if (!refs->loose) {
                /*
@@ -544,7 +544,12 @@ static struct ref_dir *get_loose_ref_dir(struct files_ref_store *refs)
                add_entry_to_dir(get_ref_dir(refs->loose->root),
                                 create_dir_entry(refs->loose, "refs/", 5, 1));
        }
-       return get_ref_dir(refs->loose->root);
+       return refs->loose;
+}
+
+static struct ref_dir *get_loose_ref_dir(struct files_ref_store *refs)
+{
+       return get_ref_dir(get_loose_ref_cache(refs)->root);
 }
 
 /*