diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-01-23 15:46:14 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-02-09 12:10:40 +0000 |
commit | 894543827d7ad62c7b70901e949305beea34cdbd (patch) | |
tree | 27223b2282ac15992c3fbf213cde55802da89df8 /src | |
parent | cdf5ae9ff6aab6655a1cc361e998462f260bcf0b (diff) | |
download | libgit2-894543827d7ad62c7b70901e949305beea34cdbd.tar.gz |
core: allow users to configure home directory
Some callers -- like our test suite and the test suites of our language
bindings -- want to isolate the home directory to avoid accidentally
including the executing user's actual home directory data.
Previously, we combined the notion of a home directory and global
configuration -- now that this is separated, we provide users the
ability to configure both.
Diffstat (limited to 'src')
-rw-r--r-- | src/libgit2/libgit2.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libgit2/libgit2.c b/src/libgit2/libgit2.c index 2fda0722e..f225122e5 100644 --- a/src/libgit2/libgit2.c +++ b/src/libgit2/libgit2.c @@ -414,6 +414,25 @@ int git_libgit2_opts(int key, ...) git_repository__validate_ownership = (va_arg(ap, int) != 0); break; + case GIT_OPT_GET_HOMEDIR: + { + git_buf *out = va_arg(ap, git_buf *); + git_str str = GIT_STR_INIT; + const git_str *tmp; + + if ((error = git_buf_tostr(&str, out)) < 0 || + (error = git_sysdir_get(&tmp, GIT_SYSDIR_HOME)) < 0 || + (error = git_str_put(&str, tmp->ptr, tmp->size)) < 0) + break; + + error = git_buf_fromstr(out, &str); + } + break; + + case GIT_OPT_SET_HOMEDIR: + error = git_sysdir_set(GIT_SYSDIR_HOME, va_arg(ap, const char *)); + break; + default: git_error_set(GIT_ERROR_INVALID, "invalid option key"); error = -1; |