sha1_file: allow map_sha1_file_1 to handle arbitrary repositories
authorJonathan Nieder <jrnieder@gmail.com>
Fri, 23 Mar 2018 17:21:19 +0000 (18:21 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2018 17:05:55 +0000 (10:05 -0700)
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c
index 1fa32c8a0607d2769060e1265bac05bc3342a9a0..1d5d23dfe2e99b2eb34f5f57786582096472123d 100644 (file)
@@ -929,10 +929,8 @@ static int open_sha1_file(struct repository *r,
  * Map the loose object at "path" if it is not NULL, or the path found by
  * searching for a loose object named "sha1".
  */
  * Map the loose object at "path" if it is not NULL, or the path found by
  * searching for a loose object named "sha1".
  */
-#define map_sha1_file_1(r, p, s, si) map_sha1_file_1_##r(p, s, si)
-static void *map_sha1_file_1_the_repository(const char *path,
-                                           const unsigned char *sha1,
-                                           unsigned long *size)
+static void *map_sha1_file_1(struct repository *r, const char *path,
+                            const unsigned char *sha1, unsigned long *size)
 {
        void *map;
        int fd;
 {
        void *map;
        int fd;
@@ -940,7 +938,7 @@ static void *map_sha1_file_1_the_repository(const char *path,
        if (path)
                fd = git_open(path);
        else
        if (path)
                fd = git_open(path);
        else
-               fd = open_sha1_file(the_repository, sha1, &path);
+               fd = open_sha1_file(r, sha1, &path);
        map = NULL;
        if (fd >= 0) {
                struct stat st;
        map = NULL;
        if (fd >= 0) {
                struct stat st;