specialrefdb: introduce a special reference database

This commit is contained in:
Edward Thomson
2026-02-01 21:44:55 +00:00
parent 8f77a5e8a6
commit 7d58de7f29
4 changed files with 45 additions and 2 deletions

View File

@@ -26,7 +26,7 @@
#include "submodule.h"
#include "diff_driver.h"
#include "grafts.h"
#include "specialrefs.h"
#include "specialref.h"
#define DOT_GIT ".git"
#define GIT_DIR DOT_GIT "/"

27
src/libgit2/specialref.c Normal file
View File

@@ -0,0 +1,27 @@
/*
* 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.
*/
#include "specialref.h"
#include "common.h"
#include "refs.h"
#include "repository.h"
#include "specialrefdb.h"
#include "git2/types.h"
#include "git2/refs.h"
int git_specialref_lookup_head(git_reference **out, git_repository *repo)
{
git_specialrefdb *db;
int error;
if ((error = git_repository_specialrefdb__weakptr(&db, repo)) < 0)
return error;
return git_specialrefdb_lookup_head(out, db);
}

16
src/libgit2/specialref.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* 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_specialref_h__
#define INCLUDE_specialref_h__
#include "common.h"
#include "git2/refs.h"
extern int git_specialref_lookup_head(git_reference **out, git_repository *repo);
#endif

View File

@@ -5,7 +5,7 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "specialrefs.h"
#include "specialref.h"
#include "git2/sys/specialrefdb_backend.h"