Skip to content

Commit e35454f

Browse files
stefanbellergitster
authored andcommitted
sha1_file: add repository argument to map_sha1_file
Add a repository argument to allow map_sha1_file callers to be more specific about which repository to handle. 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. While at it, move the declaration to object-store.h, where it should be easier to find. 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 332295d commit e35454f

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,6 @@ extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned c
12421242
extern int force_object_loose(const unsigned char *sha1, time_t mtime);
12431243
extern int git_open_cloexec(const char *name, int flags);
12441244
#define git_open(name) git_open_cloexec(name, O_RDONLY)
1245-
extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);
12461245
extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
12471246
extern int parse_sha1_header(const char *hdr, unsigned long *sizep);
12481247

object-store.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,7 @@ void raw_object_store_clear(struct raw_object_store *o);
128128
#define sha1_file_name(r, b, s) sha1_file_name_##r(b, s)
129129
void sha1_file_name_the_repository(struct strbuf *buf, const unsigned char *sha1);
130130

131+
#define map_sha1_file(r, s, sz) map_sha1_file_##r(s, sz)
132+
void *map_sha1_file_the_repository(const unsigned char *sha1, unsigned long *size);
133+
131134
#endif /* OBJECT_STORE_H */

sha1_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ static void *map_sha1_file_1_the_repository(const char *path,
961961
return map;
962962
}
963963

964-
void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
964+
void *map_sha1_file_the_repository(const unsigned char *sha1, unsigned long *size)
965965
{
966966
return map_sha1_file_1(the_repository, NULL, sha1, size);
967967
}
@@ -1185,7 +1185,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
11851185
return 0;
11861186
}
11871187

1188-
map = map_sha1_file(sha1, &mapsize);
1188+
map = map_sha1_file(the_repository, sha1, &mapsize);
11891189
if (!map)
11901190
return -1;
11911191

streaming.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*/
44
#include "cache.h"
55
#include "streaming.h"
6+
#include "repository.h"
7+
#include "object-store.h"
68
#include "packfile.h"
79

810
enum input_source {
@@ -335,7 +337,8 @@ static struct stream_vtbl loose_vtbl = {
335337

336338
static open_method_decl(loose)
337339
{
338-
st->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize);
340+
st->u.loose.mapped = map_sha1_file(the_repository,
341+
sha1, &st->u.loose.mapsize);
339342
if (!st->u.loose.mapped)
340343
return -1;
341344
if ((unpack_sha1_header(&st->z,

0 commit comments

Comments
 (0)