11#include "../helpers/Unique.h"
23class PathSpecMatchList {
24 using GitTy = git_pathspec_match_list;
28 friend class PathSpec;
30 PathSpecMatchList() =
delete;
34 return git_pathspec_match_list_entrycount(
matchList());
37 std::string
entry(
size_t pos)
const noexcept {
38 return git_pathspec_match_list_entry(
matchList(), pos);
42 const git_diff_delta *
diffEntry(
size_t pos)
const noexcept {
43 return git_pathspec_match_list_diff_entry(
matchList(), pos);
48 return git_pathspec_match_list_failed_entrycount(
matchList());
52 return git_pathspec_match_list_failed_entry(
matchList(), pos);
56 GitTy *
matchList() const noexcept {
return m_matchList.get(); }
58 operator GitTy *()
const noexcept {
return matchList(); }
69 using GitTy = git_pathspec;
77 static std::optional<PathSpec>
create(
const std::vector<std::string> &
pathSpec)
noexcept;
81 uint32_t flags = GIT_PATHSPEC_DEFAULT)
const noexcept {
82 return git_pathspec_matches_path(m_pathSpec, flags, path.c_str());
87 uint32_t flags = GIT_PATHSPEC_DEFAULT)
const noexcept;
90 uint32_t flags = GIT_PATHSPEC_DEFAULT)
const noexcept;
93 uint32_t flags = GIT_PATHSPEC_DEFAULT)
const noexcept;
96 uint32_t flags = GIT_PATHSPEC_DEFAULT)
const noexcept;
99 GitTy *
pathSpec() const noexcept {
return m_pathSpec.get(); }
101 operator GitTy *()
const noexcept {
return pathSpec(); }
Diff is a representation of a git diff.
Definition Diff.h:21
Index is a representation of a git index.
Definition Index.h:78
PathSpecMatchList is a representation of a git pathspecs match list.
Definition PathSpec.h:23
std::string entry(size_t pos) const noexcept
Get an entry on pos-th position.
Definition PathSpec.h:37
size_t entrycount() const noexcept
Get count of entries in this PathSpecMatchList.
Definition PathSpec.h:33
const git_diff_delta * diffEntry(size_t pos) const noexcept
Get a diff entry on pos-th position.
Definition PathSpec.h:42
GitTy * matchList() const noexcept
Get the stored pointer to libgit2's git_pathspec_match_list.
Definition PathSpec.h:56
size_t failedEntrycount() const noexcept
Get count of failed entries in this PathSpecMatchList.
Definition PathSpec.h:47
std::string failedEntry(size_t pos) const noexcept
Get a failed entry on pos-th position.
Definition PathSpec.h:51
PathSpec is a representation of git pathspecs.
Definition PathSpec.h:68
static std::optional< PathSpec > create(const std::vector< std::string > &pathSpec) noexcept
Create a new PathSpec, to match every path in pathSpec.
std::optional< PathSpecMatchList > matchIndex(const Index &index, uint32_t flags=GIT_PATHSPEC_DEFAULT) const noexcept
Return paths this PathSpec matches in the index.
std::optional< PathSpecMatchList > matchWorkdir(const Repo &repo, uint32_t flags=GIT_PATHSPEC_DEFAULT) const noexcept
Return paths this PathSpec matches in the workdir.
bool matchesPath(const std::string &path, uint32_t flags=GIT_PATHSPEC_DEFAULT) const noexcept
Return true if this PathSpec matches path.
Definition PathSpec.h:80
std::optional< PathSpecMatchList > matchTree(const Tree &tree, uint32_t flags=GIT_PATHSPEC_DEFAULT) const noexcept
Return paths this PathSpec matches in the tree.
std::optional< PathSpecMatchList > matchDiff(const Diff &diff, uint32_t flags=GIT_PATHSPEC_DEFAULT) const noexcept
Return paths this PathSpec matches in the diff.
GitTy * pathSpec() const noexcept
Get the stored pointer to libgit2's git_pathspec.
Definition PathSpec.h:99
The most important Git class.
Definition Repo.h:45
Tree is a representation of a git tree.
Definition Tree.h:27
Wrapper around std::unique_ptr for easier re-definition of free.
Definition Unique.h:41