Пример #1
0
int
load_git_config(void)
{
	const char *config_list_argv[] = { "git", "config", "--list", NULL };

	return io_run_load(config_list_argv, "=", read_repo_config_option, NULL);
}
Пример #2
0
static enum status_code
reload_repo_info(const char **rev_parse_argv)
{
    struct repo_info_state state = { rev_parse_argv + 2 };

    return io_run_load(rev_parse_argv, "=", read_repo_info, &state);
}
Пример #3
0
Файл: refdb.c Проект: JakeSc/tig
static int
reload_refs(bool force)
{
	const char *head_argv[] = {
		"git", "symbolic-ref", "HEAD", NULL
	};
	const char *ls_remote_argv[SIZEOF_ARG] = {
		"git", "ls-remote", repo.git_dir, NULL
	};
	static bool init = FALSE;
	struct ref_opt opt = { repo.remote, repo.head, WATCH_NONE };
	struct repo_info old_repo = repo;
	size_t i;

	if (!init) {
		if (!argv_from_env(ls_remote_argv, "TIG_LS_REMOTE"))
			return ERR;
		init = TRUE;
	}

	if (!*repo.git_dir)
		return OK;

	if ((force || !*repo.head) && io_run_buf(head_argv, repo.head, sizeof(repo.head)) &&
	    !prefixcmp(repo.head, "refs/heads/")) {
		char *offset = repo.head + STRING_SIZE("refs/heads/");

		memmove(repo.head, offset, strlen(offset) + 1);
	}

	if (strcmp(old_repo.head, repo.head))
		opt.changed |= WATCH_HEAD;

	refs_head = NULL;
	for (i = 0; i < refs_size; i++)
		refs[i]->valid = 0;

	done_ref_lists();

	if (io_run_load(ls_remote_argv, "\t", read_ref, &opt) == ERR)
		return ERR;

	for (i = 0; i < refs_size; i++)
		if (!refs[i]->valid) {
			refs[i]->id[0] = 0;
			opt.changed |= WATCH_REFS;
		}


	if (opt.changed)
		watch_apply(NULL, opt.changed);
	qsort(refs, refs_size, sizeof(*refs), compare_refs);

	return OK;
}
Пример #4
0
Файл: repo.c Проект: Brijen/tig
int
load_repo_info(void)
{
	const char *rev_parse_argv[] = {
		"git", "rev-parse", REPO_INFO_GIT_DIR, REPO_INFO_WORK_TREE,
			REPO_INFO_SHOW_CDUP, REPO_INFO_SHOW_PREFIX, \
			REPO_INFO_RESOLVED_HEAD, REPO_INFO_SYMBOLIC_HEAD, "HEAD",
			NULL
	};
	struct repo_info_state state = { rev_parse_argv + 2 };

	return io_run_load(rev_parse_argv, "=", read_repo_info, &state);
}
Пример #5
0
static void
filter_rev_parse(const char ***args, const char *arg1, const char *arg2, const char *argv[])
{
	const char *rev_parse_argv[SIZEOF_ARG] = { "git", "rev-parse", arg1, arg2 };
	const char **all_argv = NULL;

	if (!argv_append_array(&all_argv, rev_parse_argv) ||
	    !argv_append_array(&all_argv, argv) ||
	    io_run_load(all_argv, "\n", read_filter_args, args) != SUCCESS)
		die("Failed to split arguments");
	argv_free(all_argv);
	free(all_argv);
}
Пример #6
0
static int
reload_refs(bool force)
{
	const char *ls_remote_argv[SIZEOF_ARG] = {
		"git", "ls-remote", repo.git_dir, NULL
	};
	static bool init = FALSE;
	struct ref_opt opt = { repo.remote, repo.head, WATCH_NONE };
	struct repo_info old_repo = repo;
	size_t i;

	if (!init) {
		if (!argv_from_env(ls_remote_argv, "TIG_LS_REMOTE"))
			return ERR;
		init = TRUE;
	}

	if (!*repo.git_dir)
		return OK;

	if (force || !*repo.head)
		load_repo_head();

	if (strcmp(old_repo.head, repo.head))
		opt.changed |= WATCH_HEAD;

	refs_head = NULL;
	for (i = 0; i < refs_size; i++)
		refs[i]->valid = 0;

	done_ref_lists();

	if (io_run_load(ls_remote_argv, "\t", read_ref, &opt) == ERR)
		return ERR;

	for (i = 0; i < refs_size; i++)
		if (!refs[i]->valid) {
			refs[i]->id[0] = 0;
			opt.changed |= WATCH_REFS;
		}


	if (opt.changed)
		watch_apply(NULL, opt.changed);
	qsort(refs, refs_size, sizeof(*refs), compare_refs);

	return OK;
}
Пример #7
0
static int
reload_refs(const char *git_dir, const char *remote_name, char *head, size_t headlen)
{
	const char *head_argv[] = {
		"git", "symbolic-ref", "HEAD", NULL
	};
	const char *ls_remote_argv[SIZEOF_ARG] = {
		"git", "ls-remote", git_dir, NULL
	};
	static bool init = FALSE;
	struct ref_opt opt = { remote_name, head };
	size_t i;

	if (!init) {
		if (!argv_from_env(ls_remote_argv, "TIG_LS_REMOTE"))
			return ERR;
		init = TRUE;
	}

	if (!*git_dir)
		return OK;

	if (!*head && io_run_buf(head_argv, head, headlen) &&
	    !prefixcmp(head, "refs/heads/")) {
		char *offset = head + STRING_SIZE("refs/heads/");

		memmove(head, offset, strlen(offset) + 1);
	}

	refs_head = NULL;
	for (i = 0; i < refs_size; i++)
		refs[i]->valid = 0;

	done_ref_lists();

	if (io_run_load(ls_remote_argv, "\t", read_ref, &opt) == ERR)
		return ERR;

	for (i = 0; i < refs_size; i++)
		if (!refs[i]->valid)
			refs[i]->id[0] = 0;

	qsort(refs, refs_size, sizeof(*refs), compare_refs);

	return OK;
}
Пример #8
0
static enum status_code
reload_refs(bool force)
{
	const char *ls_remote_argv[SIZEOF_ARG] = {
		"git", "show-ref", "--head", "--dereference", NULL
	};
	static bool init = false;
	struct ref_opt opt = { repo.remote, repo.head, WATCH_NONE };
	struct repo_info old_repo = repo;
	enum status_code code;

	if (!init) {
		if (!argv_from_env(ls_remote_argv, "TIG_LS_REMOTE"))
			return ERROR_OUT_OF_MEMORY;
		init = true;
	}

	if (!*repo.git_dir)
		return SUCCESS;

	if (force || !*repo.head)
		load_repo_head();

	if (strcmp(old_repo.head, repo.head))
		opt.changed |= WATCH_HEAD;

	refs_head = NULL;
	refs_tags = 0;
	string_map_clear(&refs_by_id);
	string_map_foreach(&refs_by_name, invalidate_refs, NULL);

	code = io_run_load(ls_remote_argv, " ", read_ref, &opt);
	if (code != SUCCESS)
		return code;

	string_map_foreach(&refs_by_name, cleanup_refs, &opt);

	if (opt.changed)
		watch_apply(NULL, opt.changed);

	return SUCCESS;
}