summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2020-06-08 21:07:36 +0200
committerPatrick Steinhardt <ps@pks.im>2020-06-09 14:57:06 +0200
commitc6184f0c4b209e462bf3f42ab20df2d13d8ee918 (patch)
tree1960a7424f9000eefd19ad8ce8b759c38ff7e516 /src/repository.c
parent6e1efcd66934bd6c5946af01a6d5b1b83b84ddb8 (diff)
downloadlibgit2-c6184f0c4b209e462bf3f42ab20df2d13d8ee918.tar.gz
tree-wide: do not compile deprecated functions with hard deprecation
When compiling libgit2 with -DDEPRECATE_HARD, we add a preprocessor definition `GIT_DEPRECATE_HARD` which causes the "git2/deprecated.h" header to be empty. As a result, no function declarations are made available to callers, but the implementations are still available to link against. This has the problem that function declarations also aren't visible to the implementations, meaning that the symbol's visibility will not be set up correctly. As a result, the resulting library may not expose those deprecated symbols at all on some platforms and thus cause linking errors. Fix the issue by conditionally compiling deprecated functions, only. While it becomes impossible to link against such a library in case one uses deprecated functions, distributors of libgit2 aren't expected to pass -DDEPRECATE_HARD anyway. Instead, users of libgit2 should manually define GIT_DEPRECATE_HARD to hide deprecated functions. Using "real" hard deprecation still makes sense in the context of CI to test we don't use deprecated symbols ourselves and in case a dependant uses libgit2 in a vendored way and knows it won't ever use any of the deprecated symbols anyway.
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/repository.c b/src/repository.c
index 580615577..5e818fb82 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2928,11 +2928,13 @@ int git_repository_init_options_init(
return 0;
}
+#ifndef GIT_DEPRECATE_HARD
int git_repository_init_init_options(
git_repository_init_options *opts, unsigned int version)
{
return git_repository_init_options_init(opts, version);
}
+#endif
int git_repository_ident(const char **name, const char **email, const git_repository *repo)
{