1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 /** 8 * License: GPL-2.0(Linking Exception) 9 */ 10 module libgit2.sys.repository; 11 12 13 private static import libgit2.types; 14 private import libgit2.common: GIT_EXTERN; 15 16 /* 17 * @file git2/sys/repository.h 18 * @brief Git repository custom implementation routines 19 * @defgroup git_backend Git custom backend APIs 20 * @ingroup Git 21 * @{ 22 */ 23 extern (C): 24 nothrow @nogc: 25 26 /** 27 * Create a new repository with neither backends nor config object 28 * 29 * Note that this is only useful if you wish to associate the repository 30 * with a non-filesystem-backed object database and config store. 31 * 32 * Caveats: since this repository has no physical location, some systems 33 * can fail to function properly: locations under $GIT_DIR, $GIT_COMMON_DIR, 34 * or $GIT_INFO_DIR are impacted. 35 * 36 * Params: 37 * out_ = The blank repository 38 * 39 * Returns: 0 on success, or an error code 40 */ 41 @GIT_EXTERN 42 int git_repository_new(libgit2.types.git_repository** out_); 43 44 /** 45 * Reset all the internal state in a repository. 46 * 47 * This will free all the mapped memory and internal objects 48 * of the repository and leave it in a "blank" state. 49 * 50 * There's no need to call this function directly unless you're 51 * trying to aggressively cleanup the repo before its 52 * deallocation. `git_repository_free` already performs this operation 53 * before deallocating the repo. 54 * 55 * Params: 56 * repo = The repository to clean up 57 * 58 * Returns: 0 on success, or an error code 59 */ 60 @GIT_EXTERN 61 int git_repository__cleanup(libgit2.types.git_repository* repo); 62 63 /** 64 * Update the filesystem config settings for an open repository 65 * 66 * When a repository is initialized, config values are set based on the 67 * properties of the filesystem that the repository is on, such as 68 * "core.ignorecase", "core.filemode", "core.symlinks", etc. If the 69 * repository is moved to a new filesystem, these properties may no 70 * longer be correct and API calls may not behave as expected. This 71 * call reruns the phase of repository initialization that sets those 72 * properties to compensate for the current filesystem of the repo. 73 * 74 * Params: 75 * repo = A repository object 76 * recurse_submodules = Should submodules be updated recursively 77 * 78 * Returns: 0 on success, < 0 on error 79 */ 80 @GIT_EXTERN 81 int git_repository_reinit_filesystem(libgit2.types.git_repository* repo, int recurse_submodules); 82 83 /** 84 * Set the configuration file for this repository 85 * 86 * This configuration file will be used for all configuration 87 * queries involving this repository. 88 * 89 * The repository will keep a reference to the config file; 90 * the user must still free the config after setting it 91 * to the repository, or it will leak. 92 * 93 * Params: 94 * repo = A repository object 95 * config = A Config object 96 * 97 * Returns: 0 on success, or an error code 98 */ 99 @GIT_EXTERN 100 int git_repository_set_config(libgit2.types.git_repository* repo, libgit2.types.git_config* config); 101 102 /** 103 * Set the Object Database for this repository 104 * 105 * The ODB will be used for all object-related operations 106 * involving this repository. 107 * 108 * The repository will keep a reference to the ODB; the user 109 * must still free the ODB object after setting it to the 110 * repository, or it will leak. 111 * 112 * Params: 113 * repo = A repository object 114 * odb = An ODB object 115 * 116 * Returns: 0 on success, or an error code 117 */ 118 @GIT_EXTERN 119 int git_repository_set_odb(libgit2.types.git_repository* repo, libgit2.types.git_odb* odb); 120 121 /** 122 * Set the Reference Database Backend for this repository 123 * 124 * The refdb will be used for all reference related operations 125 * involving this repository. 126 * 127 * The repository will keep a reference to the refdb; the user 128 * must still free the refdb object after setting it to the 129 * repository, or it will leak. 130 * 131 * Params: 132 * repo = A repository object 133 * refdb = An refdb object 134 * 135 * Returns: 0 on success, or an error code 136 */ 137 @GIT_EXTERN 138 int git_repository_set_refdb(libgit2.types.git_repository* repo, libgit2.types.git_refdb* refdb); 139 140 /** 141 * Set the index file for this repository 142 * 143 * This index will be used for all index-related operations 144 * involving this repository. 145 * 146 * The repository will keep a reference to the index file; 147 * the user must still free the index after setting it 148 * to the repository, or it will leak. 149 * 150 * Params: 151 * repo = A repository object 152 * index = An index object 153 * 154 * Returns: 0 on success, or an error code 155 */ 156 @GIT_EXTERN 157 int git_repository_set_index(libgit2.types.git_repository* repo, libgit2.types.git_index* index); 158 159 /** 160 * Set a repository to be bare. 161 * 162 * Clear the working directory and set core.bare to true. You may also 163 * want to call `git_repository_set_index(repo, null)` since a bare repo 164 * typically does not have an index, but this function will not do that 165 * for you. 166 * 167 * Params: 168 * repo = Repo to make bare 169 * 170 * Returns: 0 on success, <0 on failure 171 */ 172 @GIT_EXTERN 173 int git_repository_set_bare(libgit2.types.git_repository* repo); 174 175 /** 176 * Load and cache all submodules. 177 * 178 * Because the `.gitmodules` file is unstructured, loading submodules is an 179 * O(N) operation. Any operation (such as `git_rebase_init`) that requires 180 * accessing all submodules is O(N^2) in the number of submodules, if it 181 * has to look each one up individually. This function loads all submodules 182 * and caches them so that subsequent calls to `git_submodule_lookup` are O(1). 183 * 184 * Params: 185 * repo = the repository whose submodules will be cached. 186 */ 187 @GIT_EXTERN 188 int git_repository_submodule_cache_all(libgit2.types.git_repository* repo); 189 190 /** 191 * Clear the submodule cache. 192 * 193 * Clear the submodule cache populated by `git_repository_submodule_cache_all`. 194 * If there is no cache, do nothing. 195 * 196 * The cache incorporates data from the repository's configuration, as well 197 * as the state of the working tree, the index, and HEAD. So any time any 198 * of these has changed, the cache might become invalid. 199 * 200 * Params: 201 * repo = the repository whose submodule cache will be cleared 202 */ 203 @GIT_EXTERN 204 int git_repository_submodule_cache_clear(libgit2.types.git_repository* repo); 205 206 /* @} */