mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 18:56:59 +00:00
config: open configuration in commondir
A repository's configuartion file can always be found in the GIT_COMMON_DIR, which has been newly introduced. For normal repositories this does change nothing, but for working trees this change allows to access the shared configuration file.
This commit is contained in:
parent
e9403024fe
commit
4292837d50
@ -862,8 +862,7 @@ static int load_config(
|
||||
if ((error = git_config_new(&cfg)) < 0)
|
||||
return error;
|
||||
|
||||
error = git_buf_joinpath(
|
||||
&config_path, repo->path_repository, GIT_CONFIG_FILENAME_INREPO);
|
||||
error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG);
|
||||
if (error < 0)
|
||||
goto on_error;
|
||||
|
||||
|
45
tests/worktree/config.c
Normal file
45
tests/worktree/config.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include "clar_libgit2.h"
|
||||
#include "worktree_helpers.h"
|
||||
|
||||
#define COMMON_REPO "testrepo"
|
||||
#define WORKTREE_REPO "testrepo-worktree"
|
||||
|
||||
static worktree_fixture fixture =
|
||||
WORKTREE_FIXTURE_INIT(COMMON_REPO, WORKTREE_REPO);
|
||||
|
||||
void test_worktree_config__initialize(void)
|
||||
{
|
||||
setup_fixture_worktree(&fixture);
|
||||
}
|
||||
|
||||
void test_worktree_config__cleanup(void)
|
||||
{
|
||||
cleanup_fixture_worktree(&fixture);
|
||||
}
|
||||
|
||||
void test_worktree_config__open(void)
|
||||
{
|
||||
git_config *cfg;
|
||||
|
||||
cl_git_pass(git_repository_config(&cfg, fixture.worktree));
|
||||
cl_assert(cfg != NULL);
|
||||
|
||||
git_config_free(cfg);
|
||||
}
|
||||
|
||||
void test_worktree_config__set(void)
|
||||
{
|
||||
git_config *cfg;
|
||||
int32_t val;
|
||||
|
||||
cl_git_pass(git_repository_config(&cfg, fixture.worktree));
|
||||
cl_git_pass(git_config_set_int32(cfg, "core.dummy", 5));
|
||||
git_config_free(cfg);
|
||||
|
||||
// reopen to verify configuration has been set in the
|
||||
// common dir
|
||||
cl_git_pass(git_repository_config(&cfg, fixture.repo));
|
||||
cl_git_pass(git_config_get_int32(&val, cfg, "core.dummy"));
|
||||
cl_assert_equal_i(val, 5);
|
||||
git_config_free(cfg);
|
||||
}
|
Loading…
Reference in New Issue
Block a user