Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
85dd425
refs: handle ORIG_HEAD via the refdb
pks-t Jul 14, 2025
ee55d24
refs: handle REVERT_HEAD via the refdb
pks-t Jul 14, 2025
5740985
refs: handle CHERRY_PICK_HEAD via the refdb
pks-t Jul 14, 2025
96a418d
refs: rename GIT_STASH_FILE to indicate this is a ref
pks-t Jul 14, 2025
bfb1959
refs: introduce GIT_HEAD_REF define
pks-t Jul 14, 2025
3e82367
repository: only consider repo-level config to read repo format
pks-t Jul 21, 2025
4dac4f0
repository: wire up refStorage extension
pks-t Feb 6, 2025
be52a46
repository: allow initialization with a specific refdb type
pks-t Jul 11, 2025
fc68ee3
tests: refactor test to not circumvent the refdb when writing HEAD
pks-t Jul 11, 2025
8fcaec5
refdb: initialize on-disk data structures via the backend
pks-t Jul 11, 2025
10413fe
tests/clar: introduce `cl_repo_has_ref_format()`
pks-t Jul 29, 2025
79b3919
tests/libgit2: don't access refs via filesystem
pks-t Jul 29, 2025
6a51b9c
tests/libgit2: don't overwrite config when testing conditionals
pks-t Jul 29, 2025
60e21fb
tests/libgit2: conditional checks for the "files"-backend
pks-t Jul 29, 2025
c0b1b40
refdb_fs: defer reading the configuration
pks-t Jul 14, 2025
6cf6c8e
config_file: use the refdb to evaluate "onbranch" condition
pks-t Jul 14, 2025
c40dd7d
refdb_fs: expose function to read a loose ref
pks-t Jul 14, 2025
4d310f3
refs: always read pseudorefs as loose refs
pks-t Jul 14, 2025
d7fc1cd
Merge branch 'pks-refformat-extension' into HEAD
pks-t Aug 4, 2025
db25710
Merge branch 'pks-refdb-pseudorefs' into HEAD
pks-t Aug 4, 2025
d4ea2f3
Merge branch 'pks-test-fixes-for-reftables' into HEAD
pks-t Aug 4, 2025
1d1d1d5
deps: import reftable library
pks-t Feb 6, 2025
f891151
deps/reftable: implement system compatibility code
pks-t Jul 4, 2025
b7eaf6f
deps/reftable: drop Git-specific QSORT macro in the writer code
pks-t Jul 4, 2025
adb54c2
deps/reftable: fix compiler warning due to missing braces
pks-t Jul 7, 2025
736a75a
deps/reftable: wire up library with CMake
pks-t Jul 4, 2025
52b0ece
deps/reftable: allow passing flags to `reftable_stack_add()`
pks-t Aug 1, 2025
0abd1a6
deps/reftable: fix for concurrent compaction
pks-t Aug 4, 2025
cf19c24
deps/reftable: don't second-guess errors from flock interface
pks-t Aug 4, 2025
a5cc370
deps/reftable: don't assume `inline` to be available
pks-t Aug 4, 2025
c9a7198
deps/reftable: provide mmap and munap via system.h
pks-t Aug 5, 2025
d4f3862
deps/reftable: allow providing fstat(3p) at all
pks-t Aug 4, 2025
9b24d21
deps/reftable: allow providing sleeping-related functions
pks-t Aug 5, 2025
f7b9d26
deps/reftable: don't use fsync(3p) if none was provided
pks-t Aug 5, 2025
76a102c
deps/reftable: fix "unknown size" warning with MSVC
pks-t Aug 5, 2025
57d35b4
deps/reftable: fix type used for number of records
pks-t Aug 5, 2025
318dedf
deps/reftable: consistently include reftable-basics.h
pks-t Aug 5, 2025
1831e12
refdb: implement reftable backend
pks-t Feb 6, 2025
08d8620
refdb: wire up "reftable" storage format
pks-t Jul 11, 2025
b6196ab
tests: generate test resources for reftables
pks-t Jul 22, 2025
dd1ff7d
tests: wire up reftable tests
pks-t Jul 22, 2025
b122fb0
github: wire up reftable tests
pks-t Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
repository: allow initialization with a specific refdb type
While we only support initializing repositories with the "files"
reference backend right now, we are in the process of implementing a
second backend with the "reftable" format. And while we already have the
infrastructure to decide which format a repository should use when we
open it, we do not have infrastructure yet to create new repositories
with a different reference format.

Introduce a new field `git_repository_init_options::refdb_type`. If
unset, we'll default to the "files" backend. Otherwise though, if set to
a valid `git_refdb_t`, we will use that new format to initialize the
repostiory.

Note that for now the only thing we do is to write the "refStorage"
extension accordingly. What we explicitly don't yet do is to also handle
the backend-specific logic to initialize the refdb on disk. This will be
implemented in subsequent commits.
  • Loading branch information
pks-t committed Jul 21, 2025
commit be52a461de4ea3f45ab54fd8129e36e00d1c643b
7 changes: 7 additions & 0 deletions include/git2/repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "types.h"
#include "oid.h"
#include "odb.h"
#include "refdb.h"
#include "buffer.h"
#include "commit.h"

Expand Down Expand Up @@ -377,6 +378,12 @@ typedef struct {
*/
git_oid_t oid_type;
#endif

/**
* Type of the reference database to use for this repository, or 0 for
* default (currently "files").
*/
git_refdb_t refdb_type;
} git_repository_init_options;

/** Current version for the `git_repository_init_options` structure */
Expand Down
10 changes: 10 additions & 0 deletions src/libgit2/refdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ int git_refdb_ensure_log(git_refdb *refdb, const char *refname);
int git_refdb_lock(void **payload, git_refdb *db, const char *refname);
int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message);

GIT_INLINE(const char *) git_refdb_type_name(git_refdb_t type)
{
switch (type) {
case GIT_REFDB_FILES:
return "files";
default:
return "unknown";
}
}

GIT_INLINE(git_refdb_t) git_refdb_type_fromstr(const char *name)
{
if (strcmp(name, "files") == 0)
Expand Down
17 changes: 14 additions & 3 deletions src/libgit2/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,8 @@ static int repo_init_config(
const char *work_dir,
uint32_t flags,
uint32_t mode,
git_oid_t oid_type)
git_oid_t oid_type,
git_refdb_t refdb_type)
{
int error = 0;
git_str cfg_path = GIT_STR_INIT, worktree_path = GIT_STR_INIT;
Expand Down Expand Up @@ -2443,6 +2444,11 @@ static int repo_init_config(
SET_REPO_CONFIG(string, "extensions.objectformat", git_oid_type_name(oid_type));
}

if (refdb_type != GIT_REFDB_FILES) {
SET_REPO_CONFIG(int32, "core.repositoryformatversion", 1);
SET_REPO_CONFIG(string, "extensions.refstorage", git_refdb_type_name(refdb_type));
}

cleanup:
git_str_dispose(&cfg_path);
git_str_dispose(&worktree_path);
Expand Down Expand Up @@ -2926,6 +2932,7 @@ int git_repository_init_ext(
const char *wd;
bool is_valid;
git_oid_t oid_type = GIT_OID_DEFAULT;
git_refdb_t refdb_type = GIT_REFDB_FILES;
int error;

GIT_ASSERT_ARG(out);
Expand All @@ -2938,6 +2945,8 @@ int git_repository_init_ext(
if (opts->oid_type)
oid_type = opts->oid_type;
#endif
if (opts->refdb_type)
refdb_type = opts->refdb_type;

if ((error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)) < 0)
goto out;
Expand All @@ -2957,13 +2966,15 @@ int git_repository_init_ext(

opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT;

if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode, oid_type)) < 0)
if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode,
oid_type, refdb_type)) < 0)
goto out;

/* TODO: reinitialize the templates */
} else {
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode, oid_type)) < 0 ||
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode,
oid_type, refdb_type)) < 0 ||
(error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0)
goto out;
}
Expand Down