diff options
author | Stefan Beller <sbeller@google.com> | 2017-08-29 23:58:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-07 08:49:44 +0900 |
commit | ad99b2f8cbfe82486b8fa2bebe652b159d05d9a5 (patch) | |
tree | 696b4a295d39fa8568d13c3746790406815cb6e3 | |
parent | 8873f87644f78c37456f181bef1c784444a7eb08 (diff) | |
download | git-ad99b2f8cbfe82486b8fa2bebe652b159d05d9a5.tar.gz |
sha1_file: add repository argument to link_alt_odb_entries
Add a repository argument to allow the link_alt_odb_entries 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>
-rw-r--r-- | sha1_file.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c index 29cead6d2c..7938bd2a6f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -401,8 +401,12 @@ static const char *parse_alt_odb_entry(const char *string, return end; } -static void link_alt_odb_entries(const char *alt, int len, int sep, - const char *relative_base, int depth) +#define link_alt_odb_entries(r, a, l, s, rb, d) \ + link_alt_odb_entries_##r(a, l, s, rb, d) +static void link_alt_odb_entries_the_repository(const char *alt, int len, + int sep, + const char *relative_base, + int depth) { struct strbuf objdirbuf = STRBUF_INIT; struct strbuf entry = STRBUF_INIT; @@ -451,7 +455,7 @@ static void read_info_alternates_the_repository(const char *relative_base, map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - link_alt_odb_entries(map, mapsz, '\n', relative_base, depth); + link_alt_odb_entries(the_repository, map, mapsz, '\n', relative_base, depth); munmap(map, mapsz); } @@ -508,7 +512,8 @@ void add_to_alternates_file(const char *reference) if (commit_lock_file(lock)) die_errno("unable to move new alternates file into place"); if (the_repository->objects.alt_odb_tail) - link_alt_odb_entries(reference, strlen(reference), '\n', NULL, 0); + link_alt_odb_entries(the_repository, reference, + strlen(reference), '\n', NULL, 0); } free(alts); } @@ -521,7 +526,8 @@ void add_to_alternates_memory(const char *reference) */ prepare_alt_odb(); - link_alt_odb_entries(reference, strlen(reference), '\n', NULL, 0); + link_alt_odb_entries(the_repository, reference, strlen(reference), + '\n', NULL, 0); } /* @@ -625,7 +631,8 @@ void prepare_alt_odb(void) the_repository->objects.alt_odb_tail = &the_repository->objects.alt_odb_list; - link_alt_odb_entries(alt, strlen(alt), PATH_SEP, NULL, 0); + link_alt_odb_entries(the_repository, alt, strlen(alt), + PATH_SEP, NULL, 0); read_info_alternates(the_repository, get_object_directory(), 0); } |