コード例 #1
0
int git_get_config(const char *key, char *buffer, int size, char *git_path)
{
	char *local, *global;
	const char *home, *system;
	struct config_buf buf;
	buf.buf=buffer;
	buf.size=size;
	buf.seen = 0;
	buf.key = key;

	local=global=system=NULL;

	home = get_windows_home_directory();
	if (home)
		global = xstrdup(mkpath("%s/.gitconfig", home));

	system = git_etc_gitconfig();

	local = git_pathdup("config");

	if ( !buf.seen)
		git_config_from_file(get_config, local, &buf);
	if (!buf.seen && global)
		git_config_from_file(get_config, global, &buf);
	if (!buf.seen && system)
		git_config_from_file(get_config, system, &buf);

	if(local)
		free(local);
	if(global)
		free(global);

	return !buf.seen;
}
コード例 #2
0
ファイル: gitdll.c プロジェクト: DinaraRigon/TortoiseGit
int get_set_config(const char *key, const char *value, CONFIG_TYPE type)
{
	char * config_exclusive_filename = NULL;

	switch(type)
	{
	case CONFIG_LOCAL:
		config_exclusive_filename  = git_pathdup("config");
		break;
	case CONFIG_GLOBAL:
	case CONFIG_XDGGLOBAL:
		{
			const char *home = get_windows_home_directory();
			if (home)
			{
				if (type == CONFIG_GLOBAL)
					config_exclusive_filename = xstrdup(mkpath("%s/.gitconfig", home));
				else
					config_exclusive_filename = xstrdup(mkpath("%s/.config/git/config", home));
			}
		}
		break;
	}

	if(!config_exclusive_filename)
		return -1;

	return git_config_set_multivar_in_file(config_exclusive_filename, key, value, NULL, 0);
}
コード例 #3
0
ファイル: gitdll.c プロジェクト: Josh-Googler/TortoiseGit
int git_get_config(const char *key, char *buffer, int size)
{
	char *local, *global, *globalxdg;
	const char *home, *system;
	struct config_buf buf;
	struct git_config_source config_source = { 0 };

	buf.buf=buffer;
	buf.size=size;
	buf.seen = 0;
	buf.key = key;

	home = get_windows_home_directory();
	if (home)
	{
		global = xstrdup(mkpath("%s/.gitconfig", home));
		globalxdg = xstrdup(mkpath("%s/.config/git/config", home));
	}
	else
	{
		global = NULL;
		globalxdg = NULL;
	}

	system = git_etc_gitconfig();

	local = git_pathdup("config");

	if (!buf.seen)
	{
		config_source.file = local;
		git_config_with_options(get_config, &buf, &config_source, 1);
	}
	if (!buf.seen && global)
	{
		config_source.file = global;
		git_config_with_options(get_config, &buf, &config_source, 1);
	}
	if (!buf.seen && globalxdg)
	{
		config_source.file = globalxdg;
		git_config_with_options(get_config, &buf, &config_source, 1);
	}
	if (!buf.seen && system)
	{
		config_source.file = system;
		git_config_with_options(get_config, &buf, &config_source, 1);
	}

	if(local)
		free(local);
	if(global)
		free(global);
	if (globalxdg)
		free(globalxdg);

	return !buf.seen;
}
コード例 #4
0
void CSettingGitConfig::OnBnClickedEditglobalgitconfig()
{
	char charBuf[MAX_PATH];
	TCHAR buf[MAX_PATH];
	strcpy_s(charBuf, MAX_PATH, get_windows_home_directory());
	_tcscpy_s(buf, MAX_PATH, CA2CT(charBuf));
	_tcscat_s(buf, MAX_PATH, _T("\\.gitconfig"));
	// use alternative editor because of LineEndings
	CAppUtils::LaunchAlternativeEditor(buf);
}
コード例 #5
0
ファイル: gitdll.c プロジェクト: omnibs/TortoiseGit
int get_set_config(const char *key, char *value, CONFIG_TYPE type,char *git_path)
{
	char *local,*global,*system_wide,*p;
	int ret;
	local=global=system_wide=NULL;

	//local = config_exclusive_filename;
	if (!local) {
		const char *home = get_windows_home_directory();

		local=p= git_pathdup("config");
		if(git_path&&strlen(git_path))
		{
			local=xstrdup(mkpath("%s/%s", git_path, p));
			free(p);
		}
		if (git_config_global() && home)
			global = xstrdup(mkpath("%s/.gitconfig", home));
		if (git_config_system())
			system_wide = git_etc_gitconfig();
	}

	switch(type)
	{
	case CONFIG_LOCAL:
		config_exclusive_filename  = local;
		break;
	case CONFIG_GLOBAL:
		config_exclusive_filename = global;
		break;
	case CONFIG_SYSTEM:
		config_exclusive_filename = system_wide;
		break;
	default:
		config_exclusive_filename = NULL;
		break;
	}

	if(!config_exclusive_filename)
		return -1;

	ret = git_config_set(key, value);

	if(local)
		free(local);
	if(global)
		free(global);
	//if(system_wide)
	//	free(system_wide);

	return ret;
}
コード例 #6
0
ファイル: gitdll.c プロジェクト: DinaraRigon/TortoiseGit
// wchar_t wrapper for get_windows_home_directory()
const wchar_t *wget_windows_home_directory(void)
{
	static const wchar_t *home_directory = NULL;
	wchar_t wpointer[MAX_PATH];

	if (home_directory)
		return home_directory;

	if (xutftowcs_path(wpointer, get_windows_home_directory()) < 0)
		return NULL;

	home_directory = _wcsdup(wpointer);

	return home_directory;
}
コード例 #7
0
ファイル: gitdll.c プロジェクト: YueLinHo/TortoiseGit
int git_init(void)
{
	_fmode = _O_BINARY;
	_setmode(_fileno(stdin), _O_BINARY);
	_setmode(_fileno(stdout), _O_BINARY);
	_setmode(_fileno(stderr), _O_BINARY);

	cleanup_chdir_notify();
	reset_git_env();
	// set HOME if not set already
	gitsetenv("HOME", get_windows_home_directory(), 0);
	drop_all_attr_stacks();
	git_config_clear();
	g_prefix = setup_git_directory();
	git_config(git_default_config, NULL);
	invalidate_ref_cache();

	return 0;
}
コード例 #8
0
ファイル: gitdll.c プロジェクト: omnibs/TortoiseGit
int git_get_config(const char *key, char *buffer, int size, char *git_path)
{
	char *local,*global,*system_wide,*p;
	struct config_buf buf;
	buf.buf=buffer;
	buf.size=size;
	buf.seen = 0;
	buf.key = key;

	local=global=system_wide=NULL;

	//local = config_exclusive_filename;
	if (!local) {
		const char *home = get_windows_home_directory();

		local=p= git_pathdup("config");
		if(git_path&&strlen(git_path))
		{
			local=xstrdup(mkpath("%s/%s", git_path, p));
			free(p);
		}
		if (git_config_global() && home)
			global = xstrdup(mkpath("%s/.gitconfig", home));
		if (git_config_system())
			system_wide = git_etc_gitconfig();
	}

	if ( !buf.seen)
		git_config_from_file(get_config, local, &buf);
	if (!buf.seen && global)
		git_config_from_file(get_config, global, &buf);
	if (!buf.seen && system_wide)
		git_config_from_file(get_config, system_wide, &buf);

	if(local)
		free(local);
	if(global)
		free(global);
	//if(system_wide)
	//	free(system_wide);

	return !buf.seen;
}
コード例 #9
0
ファイル: gitdll.c プロジェクト: YueLinHo/TortoiseGit
int git_get_config(const char *key, char *buffer, int size)
{
	const char *home, *system, *programdata;
	struct config_buf buf;
	struct git_config_source config_source = { 0 };

	struct config_options opts = { 0 };
	opts.respect_includes = 1;

	buf.buf=buffer;
	buf.size=size;
	buf.seen = 0;
	buf.key = key;

	if (have_git_dir())
	{
		opts.git_dir = get_git_dir();
		char* local = git_pathdup("config");
		config_source.file = local;
		config_with_options(get_config, &buf, &config_source, &opts);
		free(local);
		if (buf.seen)
			return !buf.seen;
	}

	home = get_windows_home_directory();
	if (home)
	{
		char* global = xstrdup(mkpath("%s/.gitconfig", home));
		if (global)
		{
			config_source.file = global;
			config_with_options(get_config, &buf, &config_source, &opts);
			free(global);
			if (buf.seen)
				return !buf.seen;
		}
		char* globalxdg = xstrdup(mkpath("%s/.config/git/config", home));
		if (globalxdg)
		{
			config_source.file = globalxdg;
			config_with_options(get_config, &buf, &config_source, &opts);
			free(globalxdg);
			if (buf.seen)
				return !buf.seen;
		}
	}

	system = git_etc_gitconfig();
	if (system)
	{
		config_source.file = system;
		config_with_options(get_config, &buf, &config_source, &opts);
		if (buf.seen)
			return !buf.seen;
	}

	programdata = git_program_data_config();
	if (programdata)
	{
		config_source.file = programdata;
		config_with_options(get_config, &buf, &config_source, &opts);
	}

	return !buf.seen;
}