FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
git2cpp/src/subcommand/revlist_subcommand.cpp at 0.0.12 · QuantStack/git2cpp · GitHub
QuantStack
git2cpp
Repository navigation
Code
Issues
6
(6)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
git2cpp
/
src
/
subcommand
/
revlist_subcommand.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (42 loc) · 1.53 KB
Breadcrumbs
git2cpp
/
src
/
subcommand
/
revlist_subcommand.cpp
Copy path
File metadata and controls
50 lines (42 loc) · 1.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#
include
"
revlist_subcommand.hpp
"
#
include
"
../wrapper/repository_wrapper.hpp
"
#
include
"
../wrapper/revwalk_wrapper.hpp
"
revlist_subcommand::revlist_subcommand
(
const
libgit2_object&,
CLI
::App& app)
{
auto
* sub = app.
add_subcommand
(
"
rev-list
"
,
"
Lists commit objects in reverse chronological order
"
);
sub->
add_option
(
"
<commit>
"
, m_commit,
"
"
);
sub->
add_option
(
"
-n,--max-count
"
, m_max_count_flag,
"
Limit the output to <number> commits.
"
);
sub->
callback
(
[
this
]()
{
this
->
run
();
}
);
}
void
revlist_subcommand::run
()
{
if
(m_commit.
empty
())
{
throw
std::runtime_error
(
"
usage: git rev-list [<options>] <commit>... [--] [<path>...]
"
);
//
TODO:
//
add help
//
info
}
auto
directory =
get_current_git_path
();
auto
repo =
repository_wrapper::open
(directory);
git_oid start_commit_oid;
int
not_sha1 =
git_oid_fromstrp
(&start_commit_oid, m_commit.
c_str
());
if
(not_sha1)
{
commit_wrapper start_commit = repo.
find_commit
(m_commit);
start_commit_oid = start_commit.
oid
();
}
revwalk_wrapper walker = repo.
new_walker
();
walker.
push
(start_commit_oid);
std::
size_t
i =
0
;
git_oid commit_oid;
while
(!walker.
next
(commit_oid) && i < m_max_count_flag)
{
std::cout <<
oid_to_hex
(commit_oid) << std::endl;
++i;
}
}
Back
|
FazBrowse Home
|
New Git URL