Skip to content

Commit e00c87e

Browse files
committed
Run clang-format
1 parent 060f145 commit e00c87e

11 files changed

Lines changed: 351 additions & 304 deletions

File tree

include/libgit4cpp/Error.h

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ using ::git_error_code; // from git2/errors.h
3535

3636
namespace detail {
3737

38-
class git_category_impl : public std::error_category {
39-
public:
40-
virtual const char* name() const noexcept;
41-
virtual std::string message(int ev) const;
38+
class git_category_impl : public std::error_category
39+
{
40+
public:
41+
virtual const char* name() const noexcept;
42+
virtual std::string message(int ev) const;
4243
};
4344

4445
} // namespace detail
@@ -92,38 +93,42 @@ class Error : public std::system_error
9293
using std::system_error::system_error;
9394
Error(int ev)
9495
: std::system_error(ev, git_category())
95-
{ }
96+
{
97+
}
9698
Error(int ev, const std::string& what)
9799
: std::system_error(ev, git_category(), what)
98-
{ }
100+
{
101+
}
99102
Error(int ev, const char* what)
100103
: std::system_error(ev, git_category(), what)
101-
{ }
104+
{
105+
}
102106
Error(const std::string& what)
103107
: std::system_error(static_cast<int>(GIT_EUSER), git_category(), what)
104-
{ }
108+
{
109+
}
105110
Error(const char* what)
106111
: std::system_error(static_cast<int>(GIT_EUSER), git_category(), what)
107-
{ }
112+
{
113+
}
108114

109115
/// The error category must be an unique object
110116
const std::error_category& git_category()
111117
{
112118
static detail::git_category_impl instance;
113119
return instance;
114120
}
115-
116121
};
117122

118123
} // namespace git
119124

120-
namespace std
125+
namespace std {
126+
// register for implicit conversion to std::error_code
127+
template <>
128+
struct is_error_code_enum<git::git_error_code> : public true_type
121129
{
122-
// register for implicit conversion to std::error_code
123-
template <>
124-
struct is_error_code_enum<git::git_error_code> : public true_type
125-
{ };
126-
}
130+
};
131+
} // namespace std
127132

128133
std::error_code make_error_code(git::git_error_code e);
129134

include/libgit4cpp/Repository.h

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ namespace git {
4343
*/
4444
struct FileStatus
4545
{
46-
std::string path_name; /// Relative path to file. If the path changed this value will have the shape "OLD_NAME -> NEW_NAME".
47-
std::string handling; /// Handling status of file [unchanged, unstaged, staged, untracked, ignored]
48-
std::string changes; /// Change status of file [new file, deleted, renamed, typechanged, modified, unchanged, ignored, untracked]
49-
50-
friend std::ostream& operator<<(std::ostream& stream, FileStatus const& state) {
51-
stream << "FileStatus{ \"" << gul17::escape(state.path_name) << "\": " << state.handling << "; " << state.changes << " }";
46+
std::string
47+
path_name; /// Relative path to file. If the path changed this value will have the shape "OLD_NAME -> NEW_NAME".
48+
std::string
49+
handling; /// Handling status of file [unchanged, unstaged, staged, untracked, ignored]
50+
std::string
51+
changes; /// Change status of file [new file, deleted, renamed, typechanged, modified, unchanged, ignored, untracked]
52+
53+
friend std::ostream& operator<<(std::ostream& stream, FileStatus const& state)
54+
{
55+
stream << "FileStatus{ \"" << gul17::escape(state.path_name)
56+
<< "\": " << state.handling << "; " << state.changes << " }";
5257
return stream;
5358
}
5459
};
@@ -64,7 +69,12 @@ inline std::ostream& operator<<(std::ostream& stream, const RepoState& repostate
6469
return stream;
6570
}
6671

67-
enum class BranchType {all = 0, local =1, remote=2};
72+
enum class BranchType
73+
{
74+
all = 0,
75+
local = 1,
76+
remote = 2
77+
};
6878

6979

7080
/**
@@ -80,7 +90,6 @@ enum class BranchType {all = 0, local =1, remote=2};
8090
class Repository
8191
{
8292
public:
83-
8493
/**
8594
* Constructor which specifies the root dir of the git repository.
8695
* \param file_path Path to git directory
@@ -152,7 +161,7 @@ class Repository
152161
* files were staged successfully.
153162
* \see add()
154163
*/
155-
std::vector <int> add_files(const std::vector<std::filesystem::path>& filepaths);
164+
std::vector<int> add_files(const std::vector<std::filesystem::path>& filepaths);
156165

157166
/**
158167
* Return the commit message of the HEAD commit.
@@ -252,8 +261,8 @@ class Repository
252261
* \param origin_branch_name name of the existing branch to checkout from
253262
* \return The reference object of the new branch
254263
*/
255-
LibGitReference new_branch(const std::string& branch_name,
256-
const std::string& origin_branch_name);
264+
LibGitReference new_branch(
265+
const std::string& branch_name, const std::string& origin_branch_name);
257266

258267
/**
259268
* Returns the active branch in the repository.
@@ -276,16 +285,16 @@ class Repository
276285
* \param branch_name The branch to checkout
277286
* \param paths specifies the files to checkout
278287
*/
279-
void checkout(const std::string& branch_name,
280-
const std::vector<std::string>& paths = {"*"});
288+
void checkout(
289+
const std::string& branch_name, const std::vector<std::string>& paths = { "*" });
281290

282291
/**
283292
* Switch branches by setting HEAD to an existing branch.
284293
* \attention If the branch doesn't exist yet, no error will be thrown.
285294
* The HEAD will then be attached to an unborn branch.
286295
* \param branch_name ID, shorthand or full reference name of branch
287296
*/
288-
void switch_branch(const std::string& branch_name);
297+
void switch_branch(const std::string& branch_name);
289298

290299
/**
291300
* Remove all entries from the index under a given directory.
@@ -334,7 +343,6 @@ class Repository
334343
~Repository();
335344

336345
private:
337-
338346
/// Path to the repository.
339347
std::filesystem::path repo_path_;
340348

@@ -401,7 +409,6 @@ class Repository
401409
* \return true if file is staged (and filestats initialized), else false
402410
*/
403411
static bool is_staged(FileStatus& filestats, const git_status_entry* s);
404-
405412
};
406413

407414
} // namespace git

include/libgit4cpp/libgit4cpp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "libgit4cpp/wrapper_functions.h"
3232

3333
/// Namespace git contains all functions, classes, and other declarations of libgit4cpp.
34-
namespace git { }
34+
namespace git {
35+
}
3536

3637
#endif

include/libgit4cpp/types.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@
3030

3131
namespace git {
3232

33-
using LibGitTree = std::unique_ptr<git_tree, void(*)(git_tree*)>;
34-
using LibGitSignature = std::unique_ptr<git_signature, void(*)(git_signature*)>;
35-
using LibGitIndex = std::unique_ptr<git_index, void(*)(git_index*)>;
36-
using LibGitRepository = std::unique_ptr<git_repository, void(*)(git_repository*)>;
37-
using LibGitRemote = std::unique_ptr<git_remote, void(*)(git_remote*)>;
38-
using LibGitCommit = std::unique_ptr<git_commit, void(*)(git_commit*)>;
39-
using LibGitStatusList = std::unique_ptr<git_status_list, void(*)(git_status_list*)>;
40-
using LibGitReference = std::unique_ptr<git_reference, void(*)(git_reference*)>;
41-
using LibGitBuf = std::unique_ptr<git_buf, void(*)(git_buf*)>;
42-
using LibGitBranchIterator = std::unique_ptr<git_branch_iterator, void(*)(git_branch_iterator*)>;
33+
using LibGitTree = std::unique_ptr<git_tree, void (*)(git_tree*)>;
34+
using LibGitSignature = std::unique_ptr<git_signature, void (*)(git_signature*)>;
35+
using LibGitIndex = std::unique_ptr<git_index, void (*)(git_index*)>;
36+
using LibGitRepository = std::unique_ptr<git_repository, void (*)(git_repository*)>;
37+
using LibGitRemote = std::unique_ptr<git_remote, void (*)(git_remote*)>;
38+
using LibGitCommit = std::unique_ptr<git_commit, void (*)(git_commit*)>;
39+
using LibGitStatusList = std::unique_ptr<git_status_list, void (*)(git_status_list*)>;
40+
using LibGitReference = std::unique_ptr<git_reference, void (*)(git_reference*)>;
41+
using LibGitBuf = std::unique_ptr<git_buf, void (*)(git_buf*)>;
42+
using LibGitBranchIterator
43+
= std::unique_ptr<git_branch_iterator, void (*)(git_branch_iterator*)>;
4344

4445
} // namespace git
4546

include/libgit4cpp/wrapper_functions.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ LibGitSignature signature_default(git_repository* repo);
8282
* \param offset Timezone adjustment for the timestamp
8383
* \return new git_signature object
8484
*/
85-
LibGitSignature signature_new(const std::string& name, const std::string& email, time_t time, int offset);
85+
LibGitSignature signature_new(
86+
const std::string& name, const std::string& email, time_t time, int offset);
8687

8788

8889
/**
@@ -100,7 +101,8 @@ LibGitTree tree_lookup(git_repository* repo, git_oid tree_id);
100101
* \param status_opt Struct of status options
101102
* \return new git_status_list object
102103
*/
103-
LibGitStatusList status_list_new(git_repository* repo, const git_status_options& status_opt);
104+
LibGitStatusList status_list_new(
105+
git_repository* repo, const git_status_options& status_opt);
104106

105107
/**
106108
* Collect the reference to the repository head.
@@ -116,8 +118,8 @@ LibGitReference repository_head(git_repository* repo);
116118
* \param url Adress of remote connection, e.g https://github.com/...
117119
* \return new git_remote object
118120
*/
119-
LibGitRemote remote_create (git_repository* repo, const std::string& remote_name,
120-
const std::string& url);
121+
LibGitRemote remote_create(
122+
git_repository* repo, const std::string& remote_name, const std::string& url);
121123

122124
/**
123125
* Find a remote repository by the name under which it is configured in the given
@@ -143,7 +145,8 @@ LibGitRepository clone(const std::string& url, const std::string& repo_path);
143145
* \param branch_type Which branch type to find, enum with 1=GIT_BRANCH_LOCAL, 2=GIT_BRANCH_REMOTE, 3=GIT_BRANCH_ALL
144146
* \return new git_reference object
145147
*/
146-
LibGitReference branch_lookup(git_repository* repo, const std::string& branch_name, git_branch_t branch_type);
148+
LibGitReference branch_lookup(
149+
git_repository* repo, const std::string& branch_name, git_branch_t branch_type);
147150

148151

149152
/**
@@ -162,7 +165,8 @@ LibGitTree commit_tree(git_commit* commit);
162165
* \param force if True, it will force the creation even with uncommited changes
163166
* \return new git_reference object
164167
*/
165-
LibGitReference branch_create(git_repository* repo, const std::string& new_branch_name, const git_commit* starting_commit, int force);
168+
LibGitReference branch_create(git_repository* repo, const std::string& new_branch_name,
169+
const git_commit* starting_commit, int force);
166170

167171
/**
168172
* Find the name of a branch on the remote.

src/Error.cc

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ namespace git {
2828

2929
const std::error_category& git_category()
3030
{
31-
static detail::git_category_impl instance{ };
32-
return instance;
31+
static detail::git_category_impl instance{};
32+
return instance;
3333
}
3434

3535
namespace detail {
@@ -41,54 +41,89 @@ const char* git_category_impl::name() const noexcept
4141

4242
std::string git_category_impl::message(int ev) const
4343
{
44-
switch (static_cast<git_error_code>(ev)) {
45-
case git_error_code::GIT_OK: return "GIT_OK";
46-
case git_error_code::GIT_ERROR: return "GIT_ERROR";
47-
case git_error_code::GIT_ENOTFOUND: return "GIT_ENOTFOUND";
48-
case git_error_code::GIT_EEXISTS: return "GIT_EEXISTS";
49-
case git_error_code::GIT_EAMBIGUOUS: return "GIT_EAMBIGUOUS";
50-
case git_error_code::GIT_EBUFS: return "GIT_EBUFS";
44+
switch (static_cast<git_error_code>(ev))
45+
{
46+
case git_error_code::GIT_OK:
47+
return "GIT_OK";
48+
case git_error_code::GIT_ERROR:
49+
return "GIT_ERROR";
50+
case git_error_code::GIT_ENOTFOUND:
51+
return "GIT_ENOTFOUND";
52+
case git_error_code::GIT_EEXISTS:
53+
return "GIT_EEXISTS";
54+
case git_error_code::GIT_EAMBIGUOUS:
55+
return "GIT_EAMBIGUOUS";
56+
case git_error_code::GIT_EBUFS:
57+
return "GIT_EBUFS";
5158

52-
/**
59+
/**
5360
* GIT_EUSER is a special error that is never generated by libgit2
5461
* code. You can return it from a callback (e.g to stop an iteration)
5562
* to know that it was generated by the callback and not by libgit2.
5663
*/
57-
case git_error_code::GIT_EUSER: return "GIT_EUSER";
64+
case git_error_code::GIT_EUSER:
65+
return "GIT_EUSER";
5866

59-
case git_error_code::GIT_EBAREREPO: return "GIT_EBAREREPO";
60-
case git_error_code::GIT_EUNBORNBRANCH: return "GIT_EUNBORNBRANCH";
61-
case git_error_code::GIT_EUNMERGED: return "GIT_EUNMERGED";
62-
case git_error_code::GIT_ENONFASTFORWARD: return "GIT_ENONFASTFORWARD";
63-
case git_error_code::GIT_EINVALIDSPEC: return "GIT_EINVALIDSPEC";
64-
case git_error_code::GIT_ECONFLICT: return "GIT_ECONFLICT";
65-
case git_error_code::GIT_ELOCKED: return "GIT_ELOCKED";
66-
case git_error_code::GIT_EMODIFIED: return "GIT_EMODIFIED";
67-
case git_error_code::GIT_EAUTH: return "GIT_EAUTH";
68-
case git_error_code::GIT_ECERTIFICATE: return "GIT_ECERTIFICATE";
69-
case git_error_code::GIT_EAPPLIED: return "GIT_EAPPLIED";
70-
case git_error_code::GIT_EPEEL: return "GIT_EPEEL";
71-
case git_error_code::GIT_EEOF: return "GIT_EEOF";
72-
case git_error_code::GIT_EINVALID: return "GIT_EINVALID";
73-
case git_error_code::GIT_EUNCOMMITTED: return "GIT_EUNCOMMITTED";
74-
case git_error_code::GIT_EDIRECTORY: return "GIT_EDIRECTORY";
75-
case git_error_code::GIT_EMERGECONFLICT: return "GIT_EMERGECONFLICT";
76-
case git_error_code::GIT_PASSTHROUGH: return "GIT_PASSTHROUGH";
77-
case git_error_code::GIT_ITEROVER: return "GIT_ITEROVER";
78-
case git_error_code::GIT_RETRY: return "GIT_RETRY";
79-
case git_error_code::GIT_EMISMATCH: return "GIT_EMISMATCH";
80-
case git_error_code::GIT_EINDEXDIRTY: return "GIT_EINDEXDIRTY";
81-
case git_error_code::GIT_EAPPLYFAIL: return "GIT_EAPPLYFAIL";
67+
case git_error_code::GIT_EBAREREPO:
68+
return "GIT_EBAREREPO";
69+
case git_error_code::GIT_EUNBORNBRANCH:
70+
return "GIT_EUNBORNBRANCH";
71+
case git_error_code::GIT_EUNMERGED:
72+
return "GIT_EUNMERGED";
73+
case git_error_code::GIT_ENONFASTFORWARD:
74+
return "GIT_ENONFASTFORWARD";
75+
case git_error_code::GIT_EINVALIDSPEC:
76+
return "GIT_EINVALIDSPEC";
77+
case git_error_code::GIT_ECONFLICT:
78+
return "GIT_ECONFLICT";
79+
case git_error_code::GIT_ELOCKED:
80+
return "GIT_ELOCKED";
81+
case git_error_code::GIT_EMODIFIED:
82+
return "GIT_EMODIFIED";
83+
case git_error_code::GIT_EAUTH:
84+
return "GIT_EAUTH";
85+
case git_error_code::GIT_ECERTIFICATE:
86+
return "GIT_ECERTIFICATE";
87+
case git_error_code::GIT_EAPPLIED:
88+
return "GIT_EAPPLIED";
89+
case git_error_code::GIT_EPEEL:
90+
return "GIT_EPEEL";
91+
case git_error_code::GIT_EEOF:
92+
return "GIT_EEOF";
93+
case git_error_code::GIT_EINVALID:
94+
return "GIT_EINVALID";
95+
case git_error_code::GIT_EUNCOMMITTED:
96+
return "GIT_EUNCOMMITTED";
97+
case git_error_code::GIT_EDIRECTORY:
98+
return "GIT_EDIRECTORY";
99+
case git_error_code::GIT_EMERGECONFLICT:
100+
return "GIT_EMERGECONFLICT";
101+
case git_error_code::GIT_PASSTHROUGH:
102+
return "GIT_PASSTHROUGH";
103+
case git_error_code::GIT_ITEROVER:
104+
return "GIT_ITEROVER";
105+
case git_error_code::GIT_RETRY:
106+
return "GIT_RETRY";
107+
case git_error_code::GIT_EMISMATCH:
108+
return "GIT_EMISMATCH";
109+
case git_error_code::GIT_EINDEXDIRTY:
110+
return "GIT_EINDEXDIRTY";
111+
case git_error_code::GIT_EAPPLYFAIL:
112+
return "GIT_EAPPLYFAIL";
82113
#if LIBGIT2_FULLVERSION >= 1005000
83-
case git_error_code::GIT_EOWNER: return "GIT_EOWNER";
114+
case git_error_code::GIT_EOWNER:
115+
return "GIT_EOWNER";
84116
#if LIBGIT2_FULLVERSION >= 1007000
85-
case git_error_code::GIT_TIMEOUT: return "GIT_TIMEOUT";
117+
case git_error_code::GIT_TIMEOUT:
118+
return "GIT_TIMEOUT";
86119
#if LIBGIT2_FULLVERSION > 1007002
87-
case git_error_code::GIT_EUNCHANGED: return "GIT_EUNCHANGED";
120+
case git_error_code::GIT_EUNCHANGED:
121+
return "GIT_EUNCHANGED";
88122
#endif
89123
#endif
90124
#endif
91-
default: return "unknown GIT error";
125+
default:
126+
return "unknown GIT error";
92127
}
93128
}
94129

0 commit comments

Comments
 (0)