sha1_file: add repository argument to link_alt_odb_entry
Add a repository argument to allow the link_alt_odb_entry 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. Since the implementation does not yet work with other repositories, use a wrapper macro to enforce that the caller passes in the_repository as the first argument. It would be more appealing to use BUILD_ASSERT_OR_ZERO to enforce this, but that doesn't work because it requires a compile-time constant and common compilers like gcc 4.8.4 do not consider "r == the_repository" a compile-time constant. This and the following three patches add repository arguments to link_alt_odb_entry, read_info_alternates, link_alt_odb_entries and prepare_alt_odb. Three out of the four functions are found in a recursive call chain, calling each other, and one of them accesses the repositories `objectdir` (which was migrated; it was an obvious choice) and `ignore_env` (which we need to keep in the repository struct for clarify); hence we will pass through the repository unlike just the object store object + the ignore_env flag. 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>
This commit is contained in:
parent
13313fc333
commit
cfc62fc98c
@ -391,8 +391,9 @@ static int alt_odb_usable(struct raw_object_store *o,
|
||||
* terminating NUL.
|
||||
*/
|
||||
static void read_info_alternates(const char * relative_base, int depth);
|
||||
static int link_alt_odb_entry(const char *entry, const char *relative_base,
|
||||
int depth, const char *normalized_objdir)
|
||||
#define link_alt_odb_entry(r, e, rb, d, n) link_alt_odb_entry_##r(e, rb, d, n)
|
||||
static int link_alt_odb_entry_the_repository(const char *entry,
|
||||
const char *relative_base, int depth, const char *normalized_objdir)
|
||||
{
|
||||
struct alternate_object_database *ent;
|
||||
struct strbuf pathbuf = STRBUF_INIT;
|
||||
@ -489,7 +490,8 @@ static void link_alt_odb_entries(const char *alt, int sep,
|
||||
alt = parse_alt_odb_entry(alt, sep, &entry);
|
||||
if (!entry.len)
|
||||
continue;
|
||||
link_alt_odb_entry(entry.buf, relative_base, depth, objdirbuf.buf);
|
||||
link_alt_odb_entry(the_repository, entry.buf,
|
||||
relative_base, depth, objdirbuf.buf);
|
||||
}
|
||||
strbuf_release(&entry);
|
||||
strbuf_release(&objdirbuf);
|
||||
|
Loading…
Reference in New Issue
Block a user