Implement commits

This commit is contained in:
womax
2024-05-30 06:51:27 +02:00
parent 135dd8d4eb
commit d20d295817
17 changed files with 709 additions and 331 deletions

View File

@@ -1,11 +1,14 @@
#ifndef FS_H
#define FS_H 1
#include "objects.h"
#include "types.h"
#define LOCAL_REPO ".cgit"
#define INDEX_FILE LOCAL_REPO"/index"
#define OBJECTS_REPO LOCAL_REPO"/objects"
#define OBJECTS_DIR LOCAL_REPO"/objects"
#define REFS_DIR LOCAL_REPO"/refs"
#define HEADS_DIR REFS_DIR"/heads"
#define HEAD_FILE LOCAL_REPO"/HEAD"
#define DEFAULT_DIR_MODE 0755
#define DEFAULT_FILE_MODE 0444
@@ -15,13 +18,20 @@
#define REPO_NOT_INITIALIZED (-10)
#define OBJECT_ALREADY_EXIST (-20)
#define OBJECT_DOES_NOT_EXIST (-21)
#define FILE_NOT_FOUND (-22)
#define ENTRY_NOT_FOUND (-23)
#define WRONG_OBJECT_TYPE (-22)
#define FILE_NOT_FOUND (-30)
#define ENTRY_NOT_FOUND (-31)
int local_repo_exist();
int index_exist();
int blob_from_file(char *filename, struct object *object);
int write_object(struct object *obj);
int read_object(char *checksum, struct object *obj);
int save_index(struct tree *tree);
int load_index(struct tree *index);
int load_tree(char* checksum, struct tree *tree);
int update_head(char *new_head);
int get_last_commit(struct object *commit);
#endif // FS_H