diff options
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -367,15 +367,19 @@ static int parse_info_file_path(pull_request *pr, const char *root) { return ret; } -pull_request *get_pull_request(index_t *idx, const char *root) { +pull_request *get_pull_request(index_t *idx, const char *root, const char *repo) { /* Do we have a valid index? */ if (is_valid_index(idx)) { char *pr_dir; char *idx_str = index_to_str(idx); + char *pr_root = (!is_empty(repo)) ? dir_path_name(root, (char *)repo) : (char *)root; /* Does the converted path of our index exist? */ - if (index_path_exists(idx, root, &pr_dir) >= 0) { + if (index_path_exists(idx, (const char *)pr_root, &pr_dir) >= 0) { pull_request *pr = calloc(1, sizeof(pull_request)); + if (!is_empty(repo)) { + free(pr_root); + } log(LOG_NOTICE, "Found PR #%s with path \"%s\".", idx_str, pr_dir); @@ -390,14 +394,19 @@ pull_request *get_pull_request(index_t *idx, const char *root) { log(LOG_WARNING, "Failed to parse comments file of PR #%s.", idx_str); } + free(pr_dir); return pr; } else { log(LOG_ERR, "Failed to parse info file of PR #%s.", idx_str); free(pr); + free(pr_dir); return NULL; } } else { log(LOG_ERR, "No PR #%s found.", idx_str); + if (!is_empty(repo)) { + free(pr_root); + } free(idx_str); return NULL; } @@ -605,11 +614,12 @@ file **get_branch_commits(git_branch *br) { return NULL; } -int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root) { +int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root, const char *repo) { int ret = 0; struct stat st; file **commits; char *pr_dir; + char *pr_root = (!is_empty(repo)) ? dir_path_name(root, (char *)repo) : (char *)root; char *reason; /* Is this a NULL PR? */ @@ -619,7 +629,12 @@ int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root) { } /* Use the index as the directory path. */ - pr_dir = make_index_path(root, idx, 0); + pr_dir = make_index_path((const char *)pr_root, idx, 0); + + /* Free the PR root, if the supplied repo isn't empty. */ + if (!is_empty(repo)) { + free(pr_root); + } /* Did we fail to make an indexed path? */ if (pr_dir == NULL) { |