diff options
-rw-r--r-- | git.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -12,6 +12,7 @@ #include "config.h" #include "git.h" #include "macros.h" +#include "misc.h" git_repo *add_repo(git_repository *repo, git_repo **first, git_repo **last) { @@ -108,6 +109,33 @@ int create_pull_request_dir(pull_request *pr, const char *root) { /* Create a directory with a name of the stringified ID. */ mkdir(pr_dir, 0755); } + + /* Make patch files for each commit of PR. */ + for (int i = 0; commits[i] != NULL; i++) { + FILE *fp; + /* Does this patch file exists? */ + if (access(commits[i]->name, F_OK) == 0) { + long size = 0; + char *buf = read_file(commits[i]->name, &size); + /* 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. */ + free(buf); + continue; + } + free(buf); + } else { + continue; + } + } + + /* Create the format patch file for this commit. */ + fp = fopen(commits[i]->name, "w"); + fwrite(commits[i]->buf, sizeof(char), strlen(commits[i]->buf), fp); + fclose(fp); + } /* TODO: Implement rest of code. */ } |