mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
config: introduce GIT_CONFIG_LEVEL_WORKTREE
Introduce the logical concept of a worktree-level config. The new value sits between _LOCAL and _APP to allow `git_config_get_*` to 'just work'. The assumption of how `git_config_get_*` works was tested experimentally by setting _WORKTREE to some nonsense value (like -3) and watching the new test fail.
This commit is contained in:
@@ -48,9 +48,13 @@ typedef enum {
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_LOCAL = 5,
|
||||
|
||||
/** Worktree specific configuration file; $GIT_DIR/config.worktree
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_WORKTREE = 6,
|
||||
|
||||
/** Application specific configuration file; freely defined by applications
|
||||
*/
|
||||
GIT_CONFIG_LEVEL_APP = 6,
|
||||
GIT_CONFIG_LEVEL_APP = 7,
|
||||
|
||||
/** Represents the highest level available config file (i.e. the most
|
||||
* specific config file available that actually is loaded)
|
||||
|
||||
@@ -71,3 +71,21 @@ void test_config_configlevel__fetching_a_level_from_an_empty_compound_config_ret
|
||||
|
||||
git_config_free(cfg);
|
||||
}
|
||||
|
||||
void test_config_configlevel__can_override_local_with_worktree(void)
|
||||
{
|
||||
git_config *cfg;
|
||||
git_buf buf = GIT_BUF_INIT;
|
||||
|
||||
cl_git_pass(git_config_new(&cfg));
|
||||
cl_git_pass(git_config_add_file_ondisk(cfg, cl_fixture("config/config19"),
|
||||
GIT_CONFIG_LEVEL_WORKTREE, NULL, 1));
|
||||
cl_git_pass(git_config_add_file_ondisk(cfg, cl_fixture("config/config18"),
|
||||
GIT_CONFIG_LEVEL_LOCAL, NULL, 1));
|
||||
|
||||
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.stringglobal"));
|
||||
cl_assert_equal_s("don't find me!", buf.ptr);
|
||||
|
||||
git_buf_dispose(&buf);
|
||||
git_config_free(cfg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user