[PATCH 29/30] create_dir_entry(): allow the flag value to be passed as an argument
From: Michael Haggerty <mhagger@alum.mit.edu>
In a moment we will support multiple flag values for directory entries.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
refs.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/refs.c b/refs.c
index 4eca965..869c9a7 100644
--- a/refs.c
+++ b/refs.c
@@ -231,18 +231,18 @@ static void clear_ref_dir(struct ref_dir *dir)
}
/*
- * Create a struct ref_entry object for the specified dirname.
+ * Create a struct ref_entry object for the specified dirname and flag.
* 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(struct ref_cache *ref_cache,
- const char *dirname)
+ const char *dirname, int flag)
{
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->flag = flag;
direntry->u.subdir.ref_cache = ref_cache;
return direntry;
}
@@ -304,7 +304,7 @@ static struct ref_entry *search_for_subdir(struct ref_entry *direntry,
if (!mkdir)
return NULL;
entry = create_dir_entry(direntry->u.subdir.ref_cache,
- subdirname);
+ subdirname, REF_DIR);
add_entry(direntry, entry);
}
assert(entry->flag & REF_DIR);
@@ -768,7 +768,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, "");
+ refs->packed = create_dir_entry(refs, "", REF_DIR);
if (*refs->name)
packed_refs_file = git_path_submodule(refs->name, "packed-refs");
else
@@ -860,7 +860,7 @@ static void read_loose_refs(struct ref_entry *direntry)
static struct ref_entry *get_loose_refs(struct ref_cache *refs)
{
if (!refs->loose) {
- refs->loose = create_dir_entry(refs, "");
+ refs->loose = create_dir_entry(refs, "", REF_DIR);
read_loose_refs(search_for_subdir(refs->loose, "refs/", 1));
}
return refs->loose;
--
1.7.10