diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-07-03 10:48:23 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-07-03 10:48:23 -0400 |
commit | 1936a4303eae6dc1cc7ce072d87e3f8f365f4e64 (patch) | |
tree | 8cc0b6792e37f1e7cb7eac84f71ddb0772b1b5f6 /git.c | |
parent | 0ca215bd99dde1505dc855e4d8826ce2ce63973d (diff) |
Use the filename created by `create_num_str()`, rather
than the patch filename itself.
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -304,31 +304,36 @@ 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 = create_num_str(commits[i]->name, i); + /* Does this patch file exists? */ - if (access(commits[i]->name, F_OK) == 0) { + if (access(filename, F_OK) == 0) { long size = 0; - char *buf = read_file(commits[i]->name, &size); - log(LOG_NOTICE, "Patch file %s already exists.", commits[i]->name); + char *buf = read_file(filename, &size); + log(LOG_NOTICE, "Patch file %s already exists.", filename); /* Did we read the file? */ if (buf != NULL) { /* Are the contents of the patch file the same? */ if (strcmp(commits[i]->buf, buf) == 0) { /* Skip creating this patch file. */ - log(LOG_NOTICE, "Patch file %s is the same as the new one.", commits[i]->name); + log(LOG_NOTICE, "Patch file %s is the same as the new one.", filename); free(buf); + free(filename); continue; } free(buf); } else { - log(LOG_WARNING, "Couldn't open patch file %s.", commits[i]->name); + log(LOG_WARNING, "Couldn't open patch file %s.", filename); + free(filename); continue; } } /* Create the format patch file for this commit. */ - fp = fopen(commits[i]->name, "w"); + fp = fopen(filename, "w"); fwrite(commits[i]->buf, sizeof(char), strlen(commits[i]->buf), fp); fclose(fp); + free(filename); } if (commits != NULL && pr->pr_type) { |