sha1_file: add raw_object_store argument to alt_odb_usable

Add a raw_object_store to alt_odb_usable to be more specific about which repository to act on. The choice of the repository is delegated to its only caller link_alt_odb_entry. Signed-off-by: Stefan Beller <sbeller@google.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 13313fc333ef509465df6b681169e9842a99ae5d
1 file changed +5 -3
sha1_file.c
+5 -3
@@ -347,7 +347,9 @@ static const char *alt_sha1_path(struct alternate_object_database *alt,
347 /*
348 * Return non-zero iff the path is usable as an alternate object database.
349 */
350 -static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir)
350 +static int alt_odb_usable(struct raw_object_store *o,
351 + struct strbuf *path,
352 + const char *normalized_objdir)
353 {
354 struct alternate_object_database *alt;
355
@@ -363,7 +365,7 @@ static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir)
365 * Prevent the common mistake of listing the same
366 * thing twice, or object directory itself.
367 */
366 - for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
368 + for (alt = o->alt_odb_list; alt; alt = alt->next) {
369 if (!fspathcmp(path->buf, alt->path))
370 return 0;
371 }
@@ -415,7 +417,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base,
417 while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')
418 strbuf_setlen(&pathbuf, pathbuf.len - 1);
419
418 - if (!alt_odb_usable(&pathbuf, normalized_objdir)) {
420 + if (!alt_odb_usable(the_repository->objects, &pathbuf, normalized_objdir)) {
421 strbuf_release(&pathbuf);
422 return -1;
423 }