1 module deimos.git2.repository; 2 3 import std.conv; 4 5 import deimos.git2.common; 6 import deimos.git2.oid; 7 import deimos.git2.util; 8 import deimos.git2.types; 9 10 extern (C): 11 12 int git_repository_open(git_repository **out_, const(char)* path); 13 int git_repository_wrap_odb(git_repository **out_, git_odb *odb); 14 int git_repository_discover( 15 char *path_out, 16 size_t path_size, 17 const(char)* start_path, 18 int across_fs, 19 const(char)* ceiling_dirs); 20 21 enum git_repository_open_flag_t { 22 GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0), 23 GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1), 24 GIT_REPOSITORY_OPEN_BARE = (1 << 2), 25 } 26 mixin _ExportEnumMembers!git_repository_open_flag_t; 27 28 int git_repository_open_ext( 29 git_repository **out_, 30 const(char)* path, 31 uint flags, 32 const(char)* ceiling_dirs); 33 int git_repository_open_bare(git_repository **out_, const(char)* bare_path); 34 void git_repository_free(git_repository *repo); 35 int git_repository_init( 36 git_repository **out_, 37 const(char)* path, 38 uint is_bare); 39 40 enum git_repository_init_flag_t { 41 GIT_REPOSITORY_INIT_BARE = (1u << 0), 42 GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1), 43 GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2), 44 GIT_REPOSITORY_INIT_MKDIR = (1u << 3), 45 GIT_REPOSITORY_INIT_MKPATH = (1u << 4), 46 GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5), 47 } 48 mixin _ExportEnumMembers!git_repository_init_flag_t; 49 50 enum git_repository_init_mode_t { 51 GIT_REPOSITORY_INIT_SHARED_UMASK = octal!0, 52 GIT_REPOSITORY_INIT_SHARED_GROUP = octal!2775, 53 GIT_REPOSITORY_INIT_SHARED_ALL = octal!2777, 54 } 55 mixin _ExportEnumMembers!git_repository_init_mode_t; 56 57 struct git_repository_init_options { 58 uint version_ = GIT_REPOSITORY_INIT_OPTIONS_VERSION; 59 uint32_t flags; 60 uint32_t mode; 61 const(char)* workdir_path; 62 const(char)* description; 63 const(char)* template_path; 64 const(char)* initial_head; 65 const(char)* origin_url; 66 } 67 68 enum GIT_REPOSITORY_INIT_OPTIONS_VERSION = 1; 69 enum git_repository_init_options GIT_REPOSITORY_INIT_OPTIONS_INIT = { GIT_REPOSITORY_INIT_OPTIONS_VERSION }; 70 71 int git_repository_init_ext( 72 git_repository **out_, 73 const(char)* repo_path, 74 git_repository_init_options *opts); 75 int git_repository_head(git_reference **out_, git_repository *repo); 76 int git_repository_head_detached(git_repository *repo); 77 int git_repository_head_unborn(git_repository *repo); 78 int git_repository_is_empty(git_repository *repo); 79 const(char)* git_repository_path(git_repository *repo); 80 const(char)* git_repository_workdir(git_repository *repo); 81 int git_repository_set_workdir( 82 git_repository *repo, const(char)* workdir, int update_gitlink); 83 int git_repository_is_bare(git_repository *repo); 84 int git_repository_config(git_config **out_, git_repository *repo); 85 int git_repository_odb(git_odb **out_, git_repository *repo); 86 int git_repository_refdb(git_refdb **out_, git_repository *repo); 87 int git_repository_index(git_index **out_, git_repository *repo); 88 int git_repository_message(char *out_, size_t len, git_repository *repo); 89 int git_repository_message_remove(git_repository *repo); 90 int git_repository_merge_cleanup(git_repository *repo); 91 92 alias git_repository_fetchhead_foreach_cb = int function(const(char)* ref_name, 93 const(char)* remote_url, 94 const(git_oid)* oid, 95 uint is_merge, 96 void *payload); 97 98 int git_repository_fetchhead_foreach(git_repository *repo, 99 git_repository_fetchhead_foreach_cb callback, 100 void *payload); 101 102 alias git_repository_mergehead_foreach_cb = int function(const(git_oid)* oid, 103 void *payload); 104 105 int git_repository_mergehead_foreach(git_repository *repo, 106 git_repository_mergehead_foreach_cb callback, 107 void *payload); 108 int git_repository_hashfile( 109 git_oid *out_, 110 git_repository *repo, 111 const(char)* path, 112 git_otype type, 113 const(char)* as_path); 114 int git_repository_set_head( 115 git_repository* repo, 116 const(char)* refname); 117 int git_repository_set_head_detached( 118 git_repository* repo, 119 const(git_oid)* commitish); 120 int git_repository_detach_head( 121 git_repository* repo); 122 123 enum git_repository_state_t { 124 GIT_REPOSITORY_STATE_NONE, 125 GIT_REPOSITORY_STATE_MERGE, 126 GIT_REPOSITORY_STATE_REVERT, 127 GIT_REPOSITORY_STATE_CHERRY_PICK, 128 GIT_REPOSITORY_STATE_BISECT, 129 GIT_REPOSITORY_STATE_REBASE, 130 GIT_REPOSITORY_STATE_REBASE_INTERACTIVE, 131 GIT_REPOSITORY_STATE_REBASE_MERGE, 132 GIT_REPOSITORY_STATE_APPLY_MAILBOX, 133 GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE, 134 } 135 mixin _ExportEnumMembers!git_repository_state_t; 136 137 int git_repository_state(git_repository *repo); 138 int git_repository_set_namespace(git_repository *repo, const(char)* nmspace); 139 const(char)* git_repository_get_namespace(git_repository *repo); 140 int git_repository_is_shallow(git_repository *repo);