diff options
author | Stefan Beller <sbeller@google.com> | 2017-08-29 23:56:31 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-07 08:49:44 +0900 |
commit | 78cd9ae6736bd013e92c3559b973f7e23130ad0a (patch) | |
tree | 62eac19b82e627889ed738d3eb7943ee1ab17e9d | |
parent | b898278c126c541f40e876fe2428a98f1ed64dc9 (diff) | |
download | git-78cd9ae6736bd013e92c3559b973f7e23130ad0a.tar.gz |
sha1_file: add repository argument to alt_odb_usable
Add a repository argument to allow the alt_odb_usable 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.
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 | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c index 7c6ffd205a..1c757b44a3 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -280,7 +280,9 @@ static const char *alt_sha1_path(struct alternate_object_database *alt, /* * Return non-zero iff the path is usable as an alternate object database. */ -static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir) +#define alt_odb_usable(r, p, n) alt_odb_usable_##r(p, n) +static int alt_odb_usable_the_repository(struct strbuf *path, + const char *normalized_objdir) { struct alternate_object_database *alt; @@ -348,7 +350,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/') strbuf_setlen(&pathbuf, pathbuf.len - 1); - if (!alt_odb_usable(&pathbuf, normalized_objdir)) { + if (!alt_odb_usable(the_repository, &pathbuf, normalized_objdir)) { strbuf_release(&pathbuf); return -1; } |