sha1_file: add repository argument to read_info_alternates

See previous patch for explanation. 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>

Stefan Beller committed Mar 23, 2018 at 18:21 UTC ca5e6d26400af12cd938d468f2c21a1c895b612f
1 file changed +7 -4
sha1_file.c
+7 -4
@@ -390,7 +390,9 @@ static int alt_odb_usable(struct raw_object_store *o,
390 * SHA1, an extra slash for the first level indirection, and the
391 * terminating NUL.
392 */
393 -static void read_info_alternates(const char * relative_base, int depth);
393 +#define read_info_alternates(r, rb, d) read_info_alternates_##r(rb, d)
394 +static void read_info_alternates_the_repository(const char *relative_base,
395 + int depth);
396 #define link_alt_odb_entry(r, e, rb, d, n) link_alt_odb_entry_##r(e, rb, d, n)
397 static int link_alt_odb_entry_the_repository(const char *entry,
398 const char *relative_base, int depth, const char *normalized_objdir)
@@ -431,7 +433,7 @@ static int link_alt_odb_entry_the_repository(const char *entry,
433 ent->next = NULL;
434
435 /* recursively add alternates */
434 - read_info_alternates(pathbuf.buf, depth + 1);
436 + read_info_alternates(the_repository, pathbuf.buf, depth + 1);
437
438 strbuf_release(&pathbuf);
439 return 0;
@@ -497,7 +499,8 @@ static void link_alt_odb_entries(const char *alt, int sep,
499 strbuf_release(&objdirbuf);
500 }
501
500 -static void read_info_alternates(const char * relative_base, int depth)
502 +static void read_info_alternates_the_repository(const char *relative_base,
503 + int depth)
504 {
505 char *path;
506 struct strbuf buf = STRBUF_INIT;
@@ -678,7 +681,7 @@ void prepare_alt_odb(void)
681 link_alt_odb_entries(the_repository->objects->alternate_db,
682 PATH_SEP, NULL, 0);
683
681 - read_info_alternates(get_object_directory(), 0);
684 + read_info_alternates(the_repository, get_object_directory(), 0);
685 }
686
687 /* Returns 1 if we have successfully freshened the file, 0 otherwise. */