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