summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/git.c b/git.c
index 5408de9..4ba9f97 100644
--- a/git.c
+++ b/git.c
@@ -64,6 +64,17 @@ void cleanup_git(git_repository **repos) {
git_libgit2_shutdown();
}
+file *create_file(const char *root, const char *filename) {
+ const size_t path_len = format_len("%s/%s", root, filename);
+ char *path = calloc(path_len+1, sizeof(char));
+ long buf_size = 0;
+ file *f = calloc(1, sizeof(file));
+ sprintf(path, "%s/%s", root, filename);
+ f->name = (char *)filename;
+ f->buf = read_file(filename, &buf_size);
+ return f;
+}
+
void free_file(file *file) {
if (file->name != NULL) {
free(file->name);