[PATCH] Expose object ID computation functions.
[gitweb.git] / clone-pack.c
index 0337ceccc4153b19dcffdee8c03c373b972fc6a8..31152c7f9ad5fa1bab3a2e881682a55ab180f0b6 100644 (file)
@@ -12,7 +12,7 @@ struct ref {
        char name[0];
 };
 
-struct ref *get_remote_refs(int fd, int nr_match, char **match)
+static struct ref *get_remote_refs(int fd, int nr_match, char **match)
 {
        struct ref *ref_list = NULL, **next_ref = &ref_list;
 
@@ -68,9 +68,12 @@ static int is_master(struct ref *ref)
 static void write_one_ref(struct ref *ref)
 {
        char *path = git_path(ref->name);
-       int fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
+       int fd;
        char *hex;
 
+       if (safe_create_leading_directories(path))
+               die("unable to create leading directory for %s", ref->name);
+       fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
        if (fd < 0)
                die("unable to create ref %s", ref->name);
        hex = sha1_to_hex(ref->sha1);