Skip to content

Commit 332295d

Browse files
stefanbellergitster
authored andcommitted
sha1_file: add repository argument to map_sha1_file_1
Add a repository argument to allow the map_sha1_file_1 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 2ba0bfd commit 332295d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sha1_file.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,9 +931,10 @@ static int open_sha1_file_the_repository(const unsigned char *sha1,
931931
* Map the loose object at "path" if it is not NULL, or the path found by
932932
* searching for a loose object named "sha1".
933933
*/
934-
static void *map_sha1_file_1(const char *path,
935-
const unsigned char *sha1,
936-
unsigned long *size)
934+
#define map_sha1_file_1(r, p, s, si) map_sha1_file_1_##r(p, s, si)
935+
static void *map_sha1_file_1_the_repository(const char *path,
936+
const unsigned char *sha1,
937+
unsigned long *size)
937938
{
938939
void *map;
939940
int fd;
@@ -962,7 +963,7 @@ static void *map_sha1_file_1(const char *path,
962963

963964
void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
964965
{
965-
return map_sha1_file_1(NULL, sha1, size);
966+
return map_sha1_file_1(the_repository, NULL, sha1, size);
966967
}
967968

968969
static int unpack_sha1_short_header(git_zstream *stream,
@@ -2192,7 +2193,7 @@ int read_loose_object(const char *path,
21922193

21932194
*contents = NULL;
21942195

2195-
map = map_sha1_file_1(path, NULL, &mapsize);
2196+
map = map_sha1_file_1(the_repository, path, NULL, &mapsize);
21962197
if (!map) {
21972198
error_errno("unable to mmap %s", path);
21982199
goto out;

0 commit comments

Comments
 (0)