sha1_file: allow open_sha1_file 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>
Stefan Beller committed
Mar 23, 2018 at 18:21 UTC
ec7283e586f034404a31087c52749a6e15bb0318
1 file changed
+5
-6
sha1_file.c
+5
-6
@@ -895,9 +895,8 @@ static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
895
* Like stat_sha1_file(), but actually open the object and return the
896
* descriptor. See the caveats on the "path" parameter above.
897
*/
898
-#define open_sha1_file(r, s, p) open_sha1_file_##r(s, p)
899
-static int open_sha1_file_the_repository(const unsigned char *sha1,
900
- const char **path)
898
+static int open_sha1_file(struct repository *r,
899
+ const unsigned char *sha1, const char **path)
900
{
901
int fd;
902
struct alternate_object_database *alt;
@@ -905,7 +904,7 @@ static int open_sha1_file_the_repository(const unsigned char *sha1,
904
static struct strbuf buf = STRBUF_INIT;
905
906
strbuf_reset(&buf);
908
- sha1_file_name(the_repository, &buf, sha1);
907
+ sha1_file_name(r, &buf, sha1);
908
*path = buf.buf;
909
910
fd = git_open(*path);
@@ -913,8 +912,8 @@ static int open_sha1_file_the_repository(const unsigned char *sha1,
912
return fd;
913
most_interesting_errno = errno;
914
916
- prepare_alt_odb(the_repository);
917
- for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
915
+ prepare_alt_odb(r);
916
+ for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
917
*path = alt_sha1_path(alt, sha1);
918
fd = git_open(*path);
919
if (fd >= 0)