From 9f58d83f1d7116c824ff074184a6c90556410b5b Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 5 Aug 2022 13:40:55 -0300 Subject: git: Add `get_repo()` This function takes a null-terminated `git_repo` array, and the name of the repo to get, and will return said repo if found, and NULL if not. --- git.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'git.c') diff --git a/git.c b/git.c index b070b14..7e65323 100644 --- a/git.c +++ b/git.c @@ -576,6 +576,17 @@ file **get_branch_commits(git_branch *br) { return NULL; } +git_repo *get_repo(git_repo **repos, const char *name) { + if (!is_empty(name)) { + for (int i = 0; repos[i] != NULL; ++i) { + if (!is_empty(repos[i]->name) && !strcmp(repos[i]->name, name)) { + return repos[i]; + } + } + } + return NULL; +} + int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root, const char *repo) { int ret = 0; struct stat st; -- cgit v1.2.3-13-gbd6f