Example #1
0
Config Config::fromGlobalConfig()
{
//    git_config * def;
    git_config * cfg;
//TODO    git_config_open_default(&def); // Not available before v0.18
    if ( git_config_open_global(&cfg/*, def TODO Not available before v0.17*/ ) == GIT_OK )
        return Config(cfg);

    return Config();
}
Example #2
0
void test_config_global__open_global(void)
{
	git_config *cfg, *global, *selected, *dummy;

	cl_git_pass(git_config_open_default(&cfg));
	cl_git_pass(git_config_open_level(&global, cfg, GIT_CONFIG_LEVEL_GLOBAL));
	cl_git_fail(git_config_open_level(&dummy, cfg, GIT_CONFIG_LEVEL_XDG));
	cl_git_pass(git_config_open_global(&selected, cfg));

	git_config_free(selected);
	git_config_free(global);
	git_config_free(cfg);
}
Example #3
0
void test_config_global__open_xdg(void)
{
	git_config *cfg, *xdg, *selected;
	const char *str = "teststring";
	const char *key = "this.variable";
	git_buf buf = {0};

	cl_git_mkfile("xdg/git/config", "# XDG config\n[core]\n  test = 1\n");

	cl_git_pass(git_config_open_default(&cfg));
	cl_git_pass(git_config_open_level(&xdg, cfg, GIT_CONFIG_LEVEL_XDG));
	cl_git_pass(git_config_open_global(&selected, cfg));

	cl_git_pass(git_config_set_string(xdg, key, str));
	cl_git_pass(git_config_get_string_buf(&buf, selected, key));
	cl_assert_equal_s(str, buf.ptr);

	git_buf_free(&buf);
	git_config_free(selected);
	git_config_free(xdg);
	git_config_free(cfg);
}