]>
git.proxmox.com Git - libgit2.git/blob - include/git2/refdb.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_refdb_h__
8 #define INCLUDE_git_refdb_h__
17 * @brief Git custom refs backend functions
18 * @defgroup git_refdb Git custom refs backend API
25 * Create a new reference. Either an oid or a symbolic target must be
28 * @param refdb the reference database to associate with this reference
29 * @param name the reference name
30 * @param oid the object id for a direct reference
31 * @param symbolic the target for a symbolic reference
32 * @return the created git_reference or NULL on error
34 GIT_EXTERN(git_reference
*) git_reference__alloc(
38 const char *symbolic
);
41 * Create a new reference database with no backends.
43 * Before the Ref DB can be used for read/writing, a custom database
44 * backend must be manually set using `git_refdb_set_backend()`
46 * @param out location to store the database pointer, if opened.
47 * Set to NULL if the open failed.
48 * @param repo the repository
49 * @return 0 or an error code
51 GIT_EXTERN(int) git_refdb_new(git_refdb
**out
, git_repository
*repo
);
54 * Create a new reference database and automatically add
55 * the default backends:
57 * - git_refdb_dir: read and write loose and packed refs
58 * from disk, assuming the repository dir as the folder
60 * @param out location to store the database pointer, if opened.
61 * Set to NULL if the open failed.
62 * @param repo the repository
63 * @return 0 or an error code
65 GIT_EXTERN(int) git_refdb_open(git_refdb
**out
, git_repository
*repo
);
68 * Suggests that the given refdb compress or optimize its references.
69 * This mechanism is implementation specific. For on-disk reference
70 * databases, for example, this may pack all loose references.
72 GIT_EXTERN(int) git_refdb_compress(git_refdb
*refdb
);
75 * Close an open reference database.
77 * @param refdb reference database pointer or NULL
79 GIT_EXTERN(void) git_refdb_free(git_refdb
*refdb
);
82 * Sets the custom backend to an existing reference DB
84 * Read <refdb_backends.h> for more information.
86 * @param refdb database to add the backend to
87 * @param backend pointer to a git_refdb_backend instance
88 * @param priority Value for ordering the backends queue
89 * @return 0 on success; error code otherwise
91 GIT_EXTERN(int) git_refdb_set_backend(
93 git_refdb_backend
*backend
);