mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 11:06:32 +00:00
To support multiple different reference backend implementations, Git introduced a "refStorage" extension that stores the reference storage format a Git client should try to use. Wire up the logic to read this new extension when we open a repository from disk. For now, only the "files" backend is supported by us. When trying to open a repository that has a refstorage format that we don't understand we now error out. There are two functions that create a new repository that doesn't really have references. While those are mostly non-functional when it comes to references, we do expect that you can access the refdb, even if it's not yielding any refs. For now we mark those to use the "files" backend, so that the status quo is retained. Eventually though it might not be the worst idea to introduce an explicit "in-memory" reference database. But that is outside the scope of this patch series.
77 lines
2.1 KiB
C
77 lines
2.1 KiB
C
/*
|
|
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
*
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
* a Linking Exception. For full terms see the included COPYING file.
|
|
*/
|
|
#ifndef INCLUDE_git_refdb_h__
|
|
#define INCLUDE_git_refdb_h__
|
|
|
|
#include "common.h"
|
|
#include "types.h"
|
|
#include "oid.h"
|
|
#include "refs.h"
|
|
|
|
/**
|
|
* @file git2/refdb.h
|
|
* @brief A database for references (branches and tags)
|
|
* @defgroup git_refdb A database for references (branches and tags)
|
|
* @ingroup Git
|
|
* @{
|
|
*/
|
|
GIT_BEGIN_DECL
|
|
|
|
/** The type of the refdb as determined by "extensions.refStorage". */
|
|
typedef enum {
|
|
GIT_REFDB_FILES = 1 /**< Files backend using loose and packed refs. */
|
|
} git_refdb_t;
|
|
|
|
/**
|
|
* Create a new reference database with no backends.
|
|
*
|
|
* Before the Ref DB can be used for read/writing, a custom database
|
|
* backend must be manually set using `git_refdb_set_backend()`
|
|
*
|
|
* @param out location to store the database pointer, if opened.
|
|
* Set to NULL if the open failed.
|
|
* @param repo the repository
|
|
* @return 0 or an error code
|
|
*/
|
|
GIT_EXTERN(int) git_refdb_new(git_refdb **out, git_repository *repo);
|
|
|
|
/**
|
|
* Create a new reference database and automatically add
|
|
* the default backends:
|
|
*
|
|
* - git_refdb_dir: read and write loose and packed refs
|
|
* from disk, assuming the repository dir as the folder
|
|
*
|
|
* @param out location to store the database pointer, if opened.
|
|
* Set to NULL if the open failed.
|
|
* @param repo the repository
|
|
* @return 0 or an error code
|
|
*/
|
|
GIT_EXTERN(int) git_refdb_open(git_refdb **out, git_repository *repo);
|
|
|
|
/**
|
|
* Suggests that the given refdb compress or optimize its references.
|
|
* This mechanism is implementation specific. For on-disk reference
|
|
* databases, for example, this may pack all loose references.
|
|
*
|
|
* @param refdb The reference database to optimize.
|
|
* @return 0 or an error code.
|
|
*/
|
|
GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);
|
|
|
|
/**
|
|
* Close an open reference database.
|
|
*
|
|
* @param refdb reference database pointer or NULL
|
|
*/
|
|
GIT_EXTERN(void) git_refdb_free(git_refdb *refdb);
|
|
|
|
/** @} */
|
|
GIT_END_DECL
|
|
|
|
#endif
|