Skip to content

Commit ec7283e

Browse files
stefanbellergitster
authored andcommitted
sha1_file: allow open_sha1_file to handle arbitrary repositories
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2607fa commit ec7283e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

sha1_file.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,26 +895,25 @@ static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
895895
* Like stat_sha1_file(), but actually open the object and return the
896896
* descriptor. See the caveats on the "path" parameter above.
897897
*/
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)
901900
{
902901
int fd;
903902
struct alternate_object_database *alt;
904903
int most_interesting_errno;
905904
static struct strbuf buf = STRBUF_INIT;
906905

907906
strbuf_reset(&buf);
908-
sha1_file_name(the_repository, &buf, sha1);
907+
sha1_file_name(r, &buf, sha1);
909908
*path = buf.buf;
910909

911910
fd = git_open(*path);
912911
if (fd >= 0)
913912
return fd;
914913
most_interesting_errno = errno;
915914

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) {
918917
*path = alt_sha1_path(alt, sha1);
919918
fd = git_open(*path);
920919
if (fd >= 0)

0 commit comments

Comments
 (0)