|
||||
File indexing completed on 2025-01-18 09:59:36
0001 /* 0002 * Copyright (C) the libgit2 contributors. All rights reserved. 0003 * 0004 * This file is part of libgit2, distributed under the GNU GPL v2 with 0005 * a Linking Exception. For full terms see the included COPYING file. 0006 */ 0007 #ifndef INCLUDE_sys_git_repository_h__ 0008 #define INCLUDE_sys_git_repository_h__ 0009 0010 #include "git2/common.h" 0011 #include "git2/types.h" 0012 #include "git2/oid.h" 0013 0014 /** 0015 * @file git2/sys/repository.h 0016 * @brief Git repository custom implementation routines 0017 * @defgroup git_backend Git custom backend APIs 0018 * @ingroup Git 0019 * @{ 0020 */ 0021 GIT_BEGIN_DECL 0022 0023 /** 0024 * Create a new repository with neither backends nor config object 0025 * 0026 * Note that this is only useful if you wish to associate the repository 0027 * with a non-filesystem-backed object database and config store. 0028 * 0029 * Caveats: since this repository has no physical location, some systems 0030 * can fail to function properly: locations under $GIT_DIR, $GIT_COMMON_DIR, 0031 * or $GIT_INFO_DIR are impacted. 0032 * 0033 * @param out The blank repository 0034 * @return 0 on success, or an error code 0035 */ 0036 #ifdef GIT_EXPERIMENTAL_SHA256 0037 GIT_EXTERN(int) git_repository_new(git_repository **out, git_oid_t oid_type); 0038 #else 0039 GIT_EXTERN(int) git_repository_new(git_repository **out); 0040 #endif 0041 0042 /** 0043 * Reset all the internal state in a repository. 0044 * 0045 * This will free all the mapped memory and internal objects 0046 * of the repository and leave it in a "blank" state. 0047 * 0048 * There's no need to call this function directly unless you're 0049 * trying to aggressively cleanup the repo before its 0050 * deallocation. `git_repository_free` already performs this operation 0051 * before deallocating the repo. 0052 * 0053 * @param repo The repository to clean up 0054 * @return 0 on success, or an error code 0055 */ 0056 GIT_EXTERN(int) git_repository__cleanup(git_repository *repo); 0057 0058 /** 0059 * Update the filesystem config settings for an open repository 0060 * 0061 * When a repository is initialized, config values are set based on the 0062 * properties of the filesystem that the repository is on, such as 0063 * "core.ignorecase", "core.filemode", "core.symlinks", etc. If the 0064 * repository is moved to a new filesystem, these properties may no 0065 * longer be correct and API calls may not behave as expected. This 0066 * call reruns the phase of repository initialization that sets those 0067 * properties to compensate for the current filesystem of the repo. 0068 * 0069 * @param repo A repository object 0070 * @param recurse_submodules Should submodules be updated recursively 0071 * @return 0 on success, < 0 on error 0072 */ 0073 GIT_EXTERN(int) git_repository_reinit_filesystem( 0074 git_repository *repo, 0075 int recurse_submodules); 0076 0077 /** 0078 * Set the configuration file for this repository 0079 * 0080 * This configuration file will be used for all configuration 0081 * queries involving this repository. 0082 * 0083 * The repository will keep a reference to the config file; 0084 * the user must still free the config after setting it 0085 * to the repository, or it will leak. 0086 * 0087 * @param repo A repository object 0088 * @param config A Config object 0089 * @return 0 on success, or an error code 0090 */ 0091 GIT_EXTERN(int) git_repository_set_config(git_repository *repo, git_config *config); 0092 0093 /** 0094 * Set the Object Database for this repository 0095 * 0096 * The ODB will be used for all object-related operations 0097 * involving this repository. 0098 * 0099 * The repository will keep a reference to the ODB; the user 0100 * must still free the ODB object after setting it to the 0101 * repository, or it will leak. 0102 * 0103 * @param repo A repository object 0104 * @param odb An ODB object 0105 * @return 0 on success, or an error code 0106 */ 0107 GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb); 0108 0109 /** 0110 * Set the Reference Database Backend for this repository 0111 * 0112 * The refdb will be used for all reference related operations 0113 * involving this repository. 0114 * 0115 * The repository will keep a reference to the refdb; the user 0116 * must still free the refdb object after setting it to the 0117 * repository, or it will leak. 0118 * 0119 * @param repo A repository object 0120 * @param refdb An refdb object 0121 * @return 0 on success, or an error code 0122 */ 0123 GIT_EXTERN(int) git_repository_set_refdb(git_repository *repo, git_refdb *refdb); 0124 0125 /** 0126 * Set the index file for this repository 0127 * 0128 * This index will be used for all index-related operations 0129 * involving this repository. 0130 * 0131 * The repository will keep a reference to the index file; 0132 * the user must still free the index after setting it 0133 * to the repository, or it will leak. 0134 * 0135 * @param repo A repository object 0136 * @param index An index object 0137 * @return 0 on success, or an error code 0138 */ 0139 GIT_EXTERN(int) git_repository_set_index(git_repository *repo, git_index *index); 0140 0141 /** 0142 * Set a repository to be bare. 0143 * 0144 * Clear the working directory and set core.bare to true. You may also 0145 * want to call `git_repository_set_index(repo, NULL)` since a bare repo 0146 * typically does not have an index, but this function will not do that 0147 * for you. 0148 * 0149 * @param repo Repo to make bare 0150 * @return 0 on success, <0 on failure 0151 */ 0152 GIT_EXTERN(int) git_repository_set_bare(git_repository *repo); 0153 0154 /** 0155 * Load and cache all submodules. 0156 * 0157 * Because the `.gitmodules` file is unstructured, loading submodules is an 0158 * O(N) operation. Any operation (such as `git_rebase_init`) that requires 0159 * accessing all submodules is O(N^2) in the number of submodules, if it 0160 * has to look each one up individually. This function loads all submodules 0161 * and caches them so that subsequent calls to `git_submodule_lookup` are O(1). 0162 * 0163 * @param repo the repository whose submodules will be cached. 0164 */ 0165 GIT_EXTERN(int) git_repository_submodule_cache_all( 0166 git_repository *repo); 0167 0168 /** 0169 * Clear the submodule cache. 0170 * 0171 * Clear the submodule cache populated by `git_repository_submodule_cache_all`. 0172 * If there is no cache, do nothing. 0173 * 0174 * The cache incorporates data from the repository's configuration, as well 0175 * as the state of the working tree, the index, and HEAD. So any time any 0176 * of these has changed, the cache might become invalid. 0177 * 0178 * @param repo the repository whose submodule cache will be cleared 0179 */ 0180 GIT_EXTERN(int) git_repository_submodule_cache_clear( 0181 git_repository *repo); 0182 0183 /** @} */ 0184 GIT_END_DECL 0185 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |