git2wrap

C++20 wrapper for libgit2
git clone git://git.dimitrijedobrota.com/git2wrap.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit a6949e2ec607626dadfb1a7711a419321e57e76d
parent 09cdcdc2204d679e304b7416dd178d0736fa8016
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Thu, 22 May 2025 10:29:29 +0200

Fix enum inconsistencies

Diffstat:
M .clang-tidy | +++
M CMakeLists.txt | + -
M include/git2wrap/branch.hpp | +++++ ---
M include/git2wrap/diff.hpp | ++++++ ---
M include/git2wrap/object.hpp | + -
M include/git2wrap/repository.hpp | +++++++++ ---------------
M source/repository.cpp | +++ --
M vcpkg.json | + -

8 files changed, 29 insertions(+), 26 deletions(-)


diff --git a/ .clang-tidy b/ .clang-tidy

@@ -15,9 +15,12 @@ Checks: "*,\

-misc-include-cleaner,\
-misc-non-private-member-variables-in-classes,\
-misc-no-recursion,\
-modernize-use-designated-initializers,\
-modernize-use-trailing-return-type,\
-readability-suspicious-call-argument,\
-*-ranges,\
-cppcoreguidelines-missing-std-forward,\
-cppcoreguidelines-rvalue-reference-param-not-moved,\
"
WarningsAsErrors: ''
CheckOptions:

diff --git a/ CMakeLists.txt b/ CMakeLists.txt

@@ -16,7 +16,7 @@ include(cmake/variables.cmake)

# ---- Declare dependencies ----

find_package(libgit2 1.9 CONFIG REQUIRED)
find_package(based 0.1.2 CONFIG REQUIRED)
find_package(based 0.2.0 CONFIG REQUIRED)

# ---- Declare library ----

diff --git a/ include/git2wrap/branch.hpp b/ include/git2wrap/branch.hpp

@@ -1,6 +1,6 @@

#pragma once

#include <based/enum/enum_flag.hpp>
#include <based/enum/enum.hpp>
#include <based/types/types.hpp>
#include <git2.h>

@@ -11,6 +11,8 @@

namespace git2wrap
{

#define ENUM_LIST local, remote, all

class GIT2WRAP_EXPORT branch
{
public:

@@ -19,7 +21,7 @@ public:

);
branch(reference ref, git_branch_t type);

BASED_DECLARE_ENUM_FLAG(flags_list, based::u8, local, remote, all)
BASED_DECLARE_ENUM(flags_list, based::bu8, 1, ENUM_LIST)

operator bool() const { return m_ref; } // NOLINT
[[nodiscard]] branch dup() const;

@@ -35,7 +37,7 @@ private:

std::string m_name;
};

BASED_DEFINE_ENUM_FLAG_CLASS(branch, flags_list, based::u8, local, remote, all)
BASED_DEFINE_ENUM_CLASS(branch, flags_list, based::bu8, 1, ENUM_LIST)

class branch_iterator
{

diff --git a/ include/git2wrap/diff.hpp b/ include/git2wrap/diff.hpp

@@ -50,7 +50,7 @@ public:


BASED_DECLARE_ENUM_FLAG(
flag,
based::u32,
based::bu32,
normal,
reverse,
include_ignored,

@@ -85,7 +85,10 @@ public:

show_binary
)

auto flags() { return based::enum_flag_wrapper<flag::type>(m_options.flags); }
auto flags()
{
return based::enum_flag_wrapper<flag::enum_type>(m_options.flags);
}

private:
git_diff_options m_options = {};

@@ -94,7 +97,7 @@ private:

BASED_DEFINE_ENUM_FLAG_CLASS(
diff_options,
flag,
based::u32,
based::bu32,
normal,
reverse,
include_ignored,

diff --git a/ include/git2wrap/object.hpp b/ include/git2wrap/object.hpp

@@ -24,7 +24,7 @@ public:

object_type, int, -2, any, invalid, commit, unused, tree, blob, tag
)

using object_t = object_type::type;
using object_t = object_type::enum_type;

[[nodiscard]] oid get_id() const;
[[nodiscard]] buf get_id_short() const;

diff --git a/ include/git2wrap/repository.hpp b/ include/git2wrap/repository.hpp

@@ -16,15 +16,15 @@

namespace git2wrap
{

#define ENUM_OPEN empty, no_search, cross_fs, bare, no_dotgit, from_env

class GIT2WRAP_EXPORT repository
{
public:
using init_options = git_repository_init_options;
using clone_options = git_clone_options;

BASED_DECLARE_ENUM_FLAG(
flags_open, based::u8, no_search, cross_fs, bare, no_dotgit, from_env
)
BASED_DECLARE_ENUM_FLAG(flags_open, based::bu8, ENUM_OPEN)

explicit repository(git_repository* repo);
explicit repository(repositoryPtr repo);

@@ -41,7 +41,7 @@ public:


static repository open(const char* path);
static repository open(
const char* path, flags_open::type flags, const char* ceiling_dirs
const char* path, flags_open::enum_type flags, const char* ceiling_dirs
);

object revparse(const char* spec) const;

@@ -49,7 +49,8 @@ public:

[[nodiscard]] blob blob_lookup(const oid& objid) const;
[[nodiscard]] tag tag_lookup(const oid& objid) const;

[[nodiscard]] branch_iterator branch_begin(branch::flags_list::type flags) const;
[[nodiscard]] branch_iterator branch_begin(branch::flags_list::enum_type flags
) const;
[[nodiscard]] branch_iterator branch_end() const;

void tag_foreach(tag_foreach_cb callback, void* payload) const;

@@ -58,15 +59,8 @@ private:

repositoryPtr m_repo;
};

BASED_DEFINE_ENUM_FLAG_CLASS(
repository,
flags_open,
based::u8,
no_search,
cross_fs,
bare,
no_dotgit,
from_env
)
BASED_DEFINE_ENUM_FLAG_CLASS(repository, flags_open, based::bu8, ENUM_OPEN)

#undef ENUM_OPEN

} // namespace git2wrap

diff --git a/ source/repository.cpp b/ source/repository.cpp

@@ -64,7 +64,7 @@ repository repository::open(const char* path)

}

repository repository::open(
const char* path, flags_open::type flags, const char* ceiling_dirs
const char* path, flags_open::enum_type flags, const char* ceiling_dirs
)
{
git_repository* repo = nullptr;

@@ -146,7 +146,8 @@ branch_iterator repository::branch_end() const // NOLINT

return branch_iterator();
}

branch_iterator repository::branch_begin(branch::flags_list::type flags) const
branch_iterator repository::branch_begin(branch::flags_list::enum_type flags
) const
{
git_branch_iterator* iter = nullptr;

diff --git a/ vcpkg.json b/ vcpkg.json

@@ -8,7 +8,7 @@

},
{
"name": "based",
"version>=": "0.1.2"
"version>=": "0.2.0"
}
],
"default-features": [],