From 02abe6d08cd5c8d0f3e0a2a0e8ca375c2874254c Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 1 Aug 2021 11:33:12 -0400 Subject: Fixed a bug in `create_pull_request_dir()`. The patch file(s) were being created in the current working directory, rather than the PR directory. --- git.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/git.c b/git.c index 193c72a..230d6e9 100644 --- a/git.c +++ b/git.c @@ -324,12 +324,14 @@ int create_pull_request_dir(pull_request *pr, int id, const char *root) { /* Make patch files for each commit of PR. */ for (int i = 0; commits[i] != NULL; i++) { FILE *fp; + /*char *filename = dir_path_name(root, sanitize_str(create_num_str(commits[i]->name, i)));*/ char *filename = create_num_str(commits[i]->name, i); + char *file = dir_path_name(root, sanitize_str(filename)); /* Does this patch file exists? */ - if (access(filename, F_OK) == 0) { + if (access(file, F_OK) == 0) { long size = 0; - char *buf = read_file(filename, &size); + char *buf = read_file(file, &size); log(LOG_NOTICE, "Patch file %s already exists.", filename); /* Did we read the file? */ if (buf != NULL) { @@ -339,21 +341,24 @@ int create_pull_request_dir(pull_request *pr, int id, const char *root) { log(LOG_NOTICE, "Patch file %s is the same as the new one.", filename); free(buf); free(filename); + free(file); continue; } free(buf); } else { log(LOG_WARNING, "Couldn't open patch file %s.", filename); free(filename); + free(file); continue; } } /* Create the format patch file for this commit. */ - fp = fopen(filename, "w"); + fp = fopen(file, "w"); fwrite(commits[i]->buf, sizeof(char), strlen(commits[i]->buf), fp); fclose(fp); free(filename); + free(file); } if (commits != NULL && pr->pr_type) { -- cgit v1.2.3-13-gbd6f