sha1_file: allow sha1_loose_object_info 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 4a7c05f7d7f17cd7a42fa944e79c2ef294cb17b6
1 file changed +5 -6
sha1_file.c
+5 -6
@@ -1149,10 +1149,9 @@ int parse_sha1_header(const char *hdr, unsigned long *sizep)
1149 return parse_sha1_header_extended(hdr, &oi, 0);
1150 }
1151
1152 -#define sha1_loose_object_info(r, s, o, f) sha1_loose_object_info_##r(s, o, f)
1153 -static int sha1_loose_object_info_the_repository(const unsigned char *sha1,
1154 - struct object_info *oi,
1155 - int flags)
1152 +static int sha1_loose_object_info(struct repository *r,
1153 + const unsigned char *sha1,
1154 + struct object_info *oi, int flags)
1155 {
1156 int status = 0;
1157 unsigned long mapsize;
@@ -1176,14 +1175,14 @@ static int sha1_loose_object_info_the_repository(const unsigned char *sha1,
1175 if (!oi->typep && !oi->typename && !oi->sizep && !oi->contentp) {
1176 const char *path;
1177 struct stat st;
1179 - if (stat_sha1_file(the_repository, sha1, &st, &path) < 0)
1178 + if (stat_sha1_file(r, sha1, &st, &path) < 0)
1179 return -1;
1180 if (oi->disk_sizep)
1181 *oi->disk_sizep = st.st_size;
1182 return 0;
1183 }
1184
1186 - map = map_sha1_file(the_repository, sha1, &mapsize);
1185 + map = map_sha1_file(r, sha1, &mapsize);
1186 if (!map)
1187 return -1;
1188