Skip to content

Commit 2ba0bfd

Browse files
stefanbellergitster
authored andcommitted
sha1_file: add repository argument to open_sha1_file
Add a repository argument to allow the open_sha1_file caller to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. 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>
1 parent fbe33e2 commit 2ba0bfd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sha1_file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,9 @@ static int stat_sha1_file_the_repository(const unsigned char *sha1,
896896
* Like stat_sha1_file(), but actually open the object and return the
897897
* descriptor. See the caveats on the "path" parameter above.
898898
*/
899-
static int open_sha1_file(const unsigned char *sha1, const char **path)
899+
#define open_sha1_file(r, s, p) open_sha1_file_##r(s, p)
900+
static int open_sha1_file_the_repository(const unsigned char *sha1,
901+
const char **path)
900902
{
901903
int fd;
902904
struct alternate_object_database *alt;
@@ -939,7 +941,7 @@ static void *map_sha1_file_1(const char *path,
939941
if (path)
940942
fd = git_open(path);
941943
else
942-
fd = open_sha1_file(sha1, &path);
944+
fd = open_sha1_file(the_repository, sha1, &path);
943945
map = NULL;
944946
if (fd >= 0) {
945947
struct stat st;

0 commit comments

Comments
 (0)