Non-C external consumers of libgit.a have to redefine the `repository` object in their own language if they want to call initialize_repository() to ensure memory for the object is allocated correctly. This is not ideal for external consumers that have no need for the entire `the_repository` object but need to call other functions from an initialized repository. Therefore, add a friendly initialize_repository() wrapper without a `the_repository` pointer. Co-authored-by: Calvin Wan <calvinwan@xxxxxxxxxx> Signed-off-by: Calvin Wan <calvinwan@xxxxxxxxxx Signed-off-by: Josh Steadmon <steadmon@xxxxxxxxxx> --- repository.c | 9 +++++++++ repository.h | 1 + 2 files changed, 10 insertions(+) diff --git a/repository.c b/repository.c index 9825a30899..15cb9ee735 100644 --- a/repository.c +++ b/repository.c @@ -81,6 +81,15 @@ void initialize_repository(struct repository *repo) set_default_hash_algo(repo); } +/* + * For non-C external consumers of libgit.a that do not need access + * to the entire `the_repository` object. + */ +void initialize_the_repository(void) +{ + initialize_repository(the_repository); +} + static void expand_base_dir(char **out, const char *in, const char *base_dir, const char *def_in) { diff --git a/repository.h b/repository.h index af6ea0a62c..65c9158866 100644 --- a/repository.h +++ b/repository.h @@ -227,6 +227,7 @@ void repo_set_compat_hash_algo(struct repository *repo, int compat_algo); void repo_set_ref_storage_format(struct repository *repo, enum ref_storage_format format); void initialize_repository(struct repository *repo); +void initialize_the_repository(void); RESULT_MUST_BE_USED int repo_init(struct repository *r, const char *gitdir, const char *worktree); -- 2.46.0.rc2.264.g509ed76dc8-goog