Added creation of 'objects' and 'refs' directories.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/src/repository.c b/src/repository.c
index 6f1445d..4e5e7e6 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -35,6 +35,7 @@
#define GIT_FOLDER "/.git/"
#define GIT_OBJECTS_FOLDER "objects/"
+#define GIT_REFS_FOLDER "refs/"
#define GIT_INDEX_FILE "index"
#define GIT_HEAD_FILE "HEAD"
@@ -742,9 +743,14 @@ int git_repository_init__create_structure(git_repository_init_results* results)
{
char temp_path[GIT_PATH_MAX];
int path_len;
+ const int mode = 0755; /* or 0777 ? */
char* git_dir = results->path_repository;
+ //TODO : Ensure the parent tree structure already exists by recursively building it through gitfo_mkdir_recurs().
+ if (gitfo_mkdir_recurs(git_dir, mode))
+ return GIT_ERROR;
+
path_len = strlen(git_dir);
strcpy(temp_path, git_dir);
@@ -755,6 +761,15 @@ int git_repository_init__create_structure(git_repository_init_results* results)
return git_repository_init__reinit(results);
}
+ strcpy(temp_path + path_len, GIT_OBJECTS_FOLDER);
+ if (gitfo_mkdir(temp_path, mode))
+ return GIT_ERROR;
+
+ strcpy(temp_path + path_len, GIT_REFS_FOLDER);
+ if (gitfo_mkdir(temp_path, mode))
+ return GIT_ERROR;
+
+
/* To be implemented */
return GIT_SUCCESS;