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 #ifndef INCLUDE_git_refdb_h__
8 #define INCLUDE_git_refdb_h__
9 
10 #include "common.h"
11 #include "types.h"
12 #include "oid.h"
13 #include "refs.h"
14 
15 /**
16  * @file git2/refdb.h
17  * @brief Git custom refs backend functions
18  * @defgroup git_refdb Git custom refs backend API
19  * @ingroup Git
20  * @{
21  */
22 GIT_BEGIN_DECL
23 
24 /**
25  * Create a new reference database with no backends.
26  *
27  * Before the Ref DB can be used for read/writing, a custom database
28  * backend must be manually set using `git_refdb_set_backend()`
29  *
30  * @param out location to store the database pointer, if opened.
31  *			Set to NULL if the open failed.
32  * @param repo the repository
33  * @return 0 or an error code
34  */
35 GIT_EXTERN(int) git_refdb_new(git_refdb **out, git_repository *repo);
36 
37 /**
38  * Create a new reference database and automatically add
39  * the default backends:
40  *
41  *  - git_refdb_dir: read and write loose and packed refs
42  *      from disk, assuming the repository dir as the folder
43  *
44  * @param out location to store the database pointer, if opened.
45  *			Set to NULL if the open failed.
46  * @param repo the repository
47  * @return 0 or an error code
48  */
49 GIT_EXTERN(int) git_refdb_open(git_refdb **out, git_repository *repo);
50 
51 /**
52  * Suggests that the given refdb compress or optimize its references.
53  * This mechanism is implementation specific.  For on-disk reference
54  * databases, for example, this may pack all loose references.
55  */
56 GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);
57 
58 /**
59  * Close an open reference database.
60  *
61  * @param refdb reference database pointer or NULL
62  */
63 GIT_EXTERN(void) git_refdb_free(git_refdb *refdb);
64 
65 /** @} */
66 GIT_END_DECL
67 
68 #endif
69