fetching submodules: respect `submodule.fetchJobs` config option
[gitweb.git] / server-info.c
index d54a3d624c488aaf65bc5b46f509c2481fe73103..5a86e297b51261b5f1ae9fa6dad6fa7dc86cd4ba 100644 (file)
@@ -17,7 +17,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
        FILE *fp = NULL;
 
        safe_create_leading_directories(path);
-       fd = mkstemp(tmp);
+       fd = git_mkstemp_mode(tmp, 0666);
        if (fd < 0)
                goto out;
        fp = fdopen(fd, "w");
@@ -47,21 +47,22 @@ static int update_info_file(char *path, int (*generate)(FILE *))
        return ret;
 }
 
-static int add_info_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
+static int add_info_ref(const char *path, const struct object_id *oid,
+                       int flag, void *cb_data)
 {
        FILE *fp = cb_data;
-       struct object *o = parse_object(sha1);
+       struct object *o = parse_object(oid->hash);
        if (!o)
                return -1;
 
-       if (fprintf(fp, "%s     %s\n", sha1_to_hex(sha1), path) < 0)
+       if (fprintf(fp, "%s     %s\n", oid_to_hex(oid), path) < 0)
                return -1;
 
        if (o->type == OBJ_TAG) {
                o = deref_tag(o, path, 0);
                if (o)
                        if (fprintf(fp, "%s     %s^{}\n",
-                               sha1_to_hex(o->sha1), path) < 0)
+                               oid_to_hex(&o->oid), path) < 0)
                                return -1;
        }
        return 0;
@@ -233,6 +234,14 @@ static void init_pack_info(const char *infofile, int force)
                info[i]->new_num = i;
 }
 
+static void free_pack_info(void)
+{
+       int i;
+       for (i = 0; i < num_pack; i++)
+               free(info[i]);
+       free(info);
+}
+
 static int write_pack_info_file(FILE *fp)
 {
        int i;
@@ -252,6 +261,7 @@ static int update_info_packs(int force)
 
        init_pack_info(infofile, force);
        ret = update_info_file(infofile, write_pack_info_file);
+       free_pack_info();
        free(infofile);
        return ret;
 }