SlHelpers
Toggle main menu visibility
Loading...
Searching...
No Matches
Remote.h
1
// SPDX-License-Identifier: GPL-2.0-only
2
3
#pragma once
4
5
#include <string>
6
#include <vector>
7
8
#include <git2.h>
9
10
#include "../helpers/Unique.h"
11
12
#include "DefaultFetchCallbacks.h"
13
14
namespace
SlGit {
15
16
class
Repo
;
17
21
class
Remote {
22
using
GitTy = git_remote;
23
using
Holder =
SlHelpers::UniqueHolder<GitTy>
;
24
25
friend
class
Repo;
26
public
:
27
Remote() =
delete
;
28
30
bool
fetchRefspecs
(
FetchCallbacks
&fc,
const
std::vector<std::string> &refspecs = {},
31
int
depth = 0,
bool
tags =
true
)
const
noexcept
;
33
bool
fetchRefspecs
(
const
std::vector<std::string> &refspecs = {},
int
depth = 0,
34
bool
tags =
true
)
const
noexcept
{
35
DefaultFetchCallbacks
fc;
36
return
fetchRefspecs
(fc, refspecs, depth, tags);
37
}
38
39
bool
fetchBranches
(
const
std::vector<std::string> &branches,
int
depth = 0,
40
bool
tags =
true
) const noexcept;
42
bool
fetch
(const std::
string
&branch,
int
depth = 0,
43
bool
tags = true) const noexcept {
return
fetchBranches
({ branch }, depth, tags); }
44
46
std::string
url
() const noexcept {
return
git_remote_url(
remote
()); }
47
49
const
git_indexer_progress *
stats
() const noexcept {
return
git_remote_stats(
remote
()); }
50
52
GitTy *
remote
() const noexcept {
return
m_remote.get(); }
54
operator
GitTy *()
const
noexcept
{
return
remote
(); }
55
private
:
56
explicit
Remote
(GitTy *
remote
) noexcept : m_remote(
remote
) { }
57
58
static
int
fetchCredentials(git_credential **out,
const
char
*
url
,
59
const
char
*usernameFromUrl,
unsigned
int
allowedTypes,
60
void
*payload)
noexcept
;
61
static
int
fetchPackProgress(
int
stage, uint32_t current, uint32_t total,
void
*payload);
62
static
int
fetchSidebandProgress(
const
char
*str,
int
len,
void
*payload)
noexcept
;
63
static
int
fetchTransferProgress(
const
git_indexer_progress *
stats
,
void
*payload)
noexcept
;
64
#ifdef LIBGIT_HAS_UPDATE_REFS
65
static
int
fetchUpdateRefs(
const
char
*refname,
const
git_oid *a,
const
git_oid *b,
66
git_refspec *refspec,
void
*payload)
noexcept
;
67
#endif
68
69
Holder m_remote;
70
};
71
72
}
SlGit::DefaultFetchCallbacks
The default FetchCallbacks implementation.
Definition
DefaultFetchCallbacks.h:15
SlGit::FetchCallbacks
Callbacks invoked from Repo::clone() or Remote::fetchRefspecs().
Definition
FetchCallbacks.h:17
SlGit::Remote
Remote is a representation of a git remote.
Definition
Remote.h:21
SlGit::Remote::url
std::string url() const noexcept
Get the URL of this Remote.
Definition
Remote.h:46
SlGit::Remote::fetch
bool fetch(const std::string &branch, int depth=0, bool tags=true) const noexcept
Fetch a branch from this Remote.
Definition
Remote.h:42
SlGit::Remote::remote
GitTy * remote() const noexcept
Get the stored pointer to libgit2's git_remote.
Definition
Remote.h:52
SlGit::Remote::fetchRefspecs
bool fetchRefspecs(const std::vector< std::string > &refspecs={}, int depth=0, bool tags=true) const noexcept
Fetch refspecs from this Remote.
Definition
Remote.h:33
SlGit::Remote::fetchBranches
bool fetchBranches(const std::vector< std::string > &branches, int depth=0, bool tags=true) const noexcept
Fetch branches from this Remote.
SlGit::Remote::fetchRefspecs
bool fetchRefspecs(FetchCallbacks &fc, const std::vector< std::string > &refspecs={}, int depth=0, bool tags=true) const noexcept
Fetch refspecs from this Remote, invoking the fc callback.
SlGit::Remote::stats
const git_indexer_progress * stats() const noexcept
Get the stats of the progress.
Definition
Remote.h:49
SlGit::Repo
The most important Git class.
Definition
Repo.h:45
SlHelpers::UniqueHolder
Wrapper around std::unique_ptr for easier re-definition of free.
Definition
Unique.h:41
include
git
Remote.h
Generated by
1.17.0