sha1_file: allow sha1_loose_object_info to handle arbitrary repositories
[gitweb.git] / sha1_file.c
index 1d5d23dfe2e99b2eb34f5f57786582096472123d..0989bbd948dcd025c89c73bbfe72ab7c735e3211 100644 (file)
@@ -957,9 +957,10 @@ static void *map_sha1_file_1(struct repository *r, const char *path,
        return map;
 }
 
-void *map_sha1_file_the_repository(const unsigned char *sha1, unsigned long *size)
+void *map_sha1_file(struct repository *r,
+                   const unsigned char *sha1, unsigned long *size)
 {
-       return map_sha1_file_1(the_repository, NULL, sha1, size);
+       return map_sha1_file_1(r, NULL, sha1, size);
 }
 
 static int unpack_sha1_short_header(git_zstream *stream,
@@ -1148,10 +1149,9 @@ int parse_sha1_header(const char *hdr, unsigned long *sizep)
        return parse_sha1_header_extended(hdr, &oi, 0);
 }
 
-#define sha1_loose_object_info(r, s, o, f) sha1_loose_object_info_##r(s, o, f)
-static int sha1_loose_object_info_the_repository(const unsigned char *sha1,
-                                                struct object_info *oi,
-                                                int flags)
+static int sha1_loose_object_info(struct repository *r,
+                                 const unsigned char *sha1,
+                                 struct object_info *oi, int flags)
 {
        int status = 0;
        unsigned long mapsize;
@@ -1175,14 +1175,14 @@ static int sha1_loose_object_info_the_repository(const unsigned char *sha1,
        if (!oi->typep && !oi->typename && !oi->sizep && !oi->contentp) {
                const char *path;
                struct stat st;
-               if (stat_sha1_file(the_repository, sha1, &st, &path) < 0)
+               if (stat_sha1_file(r, sha1, &st, &path) < 0)
                        return -1;
                if (oi->disk_sizep)
                        *oi->disk_sizep = st.st_size;
                return 0;
        }
 
-       map = map_sha1_file(the_repository, sha1, &mapsize);
+       map = map_sha1_file(r, sha1, &mapsize);
        if (!map)
                return -1;