diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-08-01 11:33:12 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-08-01 11:33:12 -0400 |
commit | 02abe6d08cd5c8d0f3e0a2a0e8ca375c2874254c (patch) | |
tree | 0953539fbcec3034002dfe60ddca4a28d1f0a57c | |
parent | 9fb8bf5ca96882cc17f9e4af27ece5268023c1bc (diff) |
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.
-rw-r--r-- | git.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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) { |