Ejemplo n.º 1
0
int git_config_from_file(config_fn_t fn, const char *filename, void *data)
{
	int ret;
	FILE *f = fopen(filename, "r");

	ret = -1;
	if (f) {
		config_file top;

		/* push config-file parsing state stack */
		top.prev = cf;
		top.f = f;
		top.name = filename;
		top.linenr = 1;
		top.eof = 0;
		strbuf_init(&top.value, 1024);
		cf = ⊤

		ret = git_parse_file(fn, data);

		/* pop config-file parsing state stack */
		strbuf_release(&top.value);
		cf = top.prev;

		fclose(f);
	}
	return ret;
}
Ejemplo n.º 2
0
int git_config_from_file(config_fn_t fn, const char *filename)
{
	int ret;
	FILE *f = fopen(filename, "r");

	ret = -1;
	if (f) {
		config_file = f;
		config_file_name = filename;
		config_linenr = 1;
		ret = git_parse_file(fn);
		fclose(f);
		config_file_name = NULL;
	}
	return ret;
}