sha1_file: allow map_sha1_file_1 to handle arbitrary repositories

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>

Jonathan Nieder committed Mar 23, 2018 at 18:21 UTC 1fea63e1da74b875790e8f2c63119c79fc5b52a6
1 file changed +3 -5
sha1_file.c
+3 -5
@@ -929,10 +929,8 @@ static int open_sha1_file(struct repository *r,
929 * Map the loose object at "path" if it is not NULL, or the path found by
930 * searching for a loose object named "sha1".
931 */
932 -#define map_sha1_file_1(r, p, s, si) map_sha1_file_1_##r(p, s, si)
933 -static void *map_sha1_file_1_the_repository(const char *path,
934 - const unsigned char *sha1,
935 - unsigned long *size)
932 +static void *map_sha1_file_1(struct repository *r, const char *path,
933 + const unsigned char *sha1, unsigned long *size)
934 {
935 void *map;
936 int fd;
@@ -940,7 +938,7 @@ static void *map_sha1_file_1_the_repository(const char *path,
938 if (path)
939 fd = git_open(path);
940 else
943 - fd = open_sha1_file(the_repository, sha1, &path);
941 + fd = open_sha1_file(r, sha1, &path);
942 map = NULL;
943 if (fd >= 0) {
944 struct stat st;