diff options
author | Stefan Beller <sbeller@google.com> | 2018-03-23 18:21:04 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-26 10:05:55 -0700 |
commit | cfc62fc98c0510e9ea0eeedd473411415fd33fac (patch) | |
tree | f03a957d60f9fe79345ae64f6f0fc9ce4133577a | |
parent | sha1_file: add raw_object_store argument to alt_odb_usable (diff) | |
download | tgif-cfc62fc98c0510e9ea0eeedd473411415fd33fac.tar.xz |
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>
-rw-r--r-- | sha1_file.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c index 097c372d03..7c0ace646a 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -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); |