summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-07-26 18:30:00 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2022-07-26 18:30:31 -0300
commit9edc129c0d675b80aee9d2f382bd80ed9a43ddba (patch)
tree2348753f0ce97eb585987e909356d4e4c2485f3a /git.c
parent60780c0aa29706cd323a69b495362cc633a0c4e5 (diff)
git: Add `create_file()`
Diffstat (limited to 'git.c')
-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);