FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
git2cpp/src/wrapper/status_wrapper.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
/
wrapper
/
status_wrapper.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
155 lines (138 loc) · 4.39 KB
Breadcrumbs
git2cpp
/
src
/
wrapper
/
status_wrapper.cpp
Copy path
File metadata and controls
155 lines (138 loc) · 4.39 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#
include
"
../wrapper/status_wrapper.hpp
"
#
include
"
../utils/git_exception.hpp
"
status_list_wrapper::~status_list_wrapper
()
{
git_status_list_free
(p_resource);
p_resource =
nullptr
;
}
status_list_wrapper
status_list_wrapper::status_list
(
const
repository_wrapper& rw)
{
git_status_options opts =
GIT_STATUS_OPTIONS_INIT
;
opts.
show
=
GIT_STATUS_SHOW_INDEX_AND_WORKDIR
;
opts.
flags
=
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX
|
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR
|
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY
;
opts.
rename_threshold
=
50
;
status_list_wrapper res;
throw_if_error
(
git_status_list_new
(&(res.
p_resource
), rw, &opts));
std::
size_t
status_list_size =
git_status_list_entrycount
(res.
p_resource
);
for
(std::
size_t
i =
0
; i < status_list_size; ++i)
{
auto
entry =
git_status_byindex
(res.
p_resource
, i);
auto
s = entry->
status
;
if
(s &
GIT_STATUS_INDEX_NEW
)
{
res.
m_entries
[
GIT_STATUS_INDEX_NEW
].
push_back
(entry);
}
if
(s &
GIT_STATUS_INDEX_MODIFIED
)
{
res.
m_entries
[
GIT_STATUS_INDEX_MODIFIED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_INDEX_DELETED
)
{
res.
m_entries
[
GIT_STATUS_INDEX_DELETED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_INDEX_RENAMED
)
{
res.
m_entries
[
GIT_STATUS_INDEX_RENAMED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_INDEX_TYPECHANGE
)
{
res.
m_entries
[
GIT_STATUS_INDEX_TYPECHANGE
].
push_back
(entry);
}
if
(s &
GIT_STATUS_WT_NEW
)
{
res.
m_entries
[
GIT_STATUS_WT_NEW
].
push_back
(entry);
}
if
(s &
GIT_STATUS_WT_MODIFIED
)
{
res.
m_entries
[
GIT_STATUS_WT_MODIFIED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_WT_DELETED
)
{
res.
m_entries
[
GIT_STATUS_WT_DELETED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_WT_RENAMED
)
{
res.
m_entries
[
GIT_STATUS_WT_RENAMED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_WT_TYPECHANGE
)
{
res.
m_entries
[
GIT_STATUS_WT_TYPECHANGE
].
push_back
(entry);
}
if
(s &
GIT_STATUS_IGNORED
)
{
res.
m_entries
[
GIT_STATUS_IGNORED
].
push_back
(entry);
}
if
(s &
GIT_STATUS_CONFLICTED
)
{
res.
m_entries
[
GIT_STATUS_CONFLICTED
].
push_back
(entry);
}
}
if
(!res.
get_entry_list
(
GIT_STATUS_INDEX_NEW
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_INDEX_MODIFIED
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_INDEX_DELETED
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_INDEX_RENAMED
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_INDEX_TYPECHANGE
).
empty
())
{
res.
m_tobecommited_header_flag
=
true
;
}
if
(!res.
get_entry_list
(
GIT_STATUS_WT_NEW
).
empty
())
{
res.
m_untracked_header_flag
=
true
;
}
if
(!res.
get_entry_list
(
GIT_STATUS_WT_MODIFIED
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_WT_DELETED
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_WT_TYPECHANGE
).
empty
()
|| !res.
get_entry_list
(
GIT_STATUS_WT_RENAMED
).
empty
())
{
res.
m_notstagged_header_flag
=
true
;
}
if
(!res.
get_entry_list
(
GIT_STATUS_IGNORED
).
empty
())
{
res.
m_ignored_header_flag
=
true
;
}
if
(!res.
get_entry_list
(
GIT_STATUS_CONFLICTED
).
empty
())
{
res.
m_unmerged_header_flag
=
true
;
}
//
if (!res.tobecommited_header_flag)
//
{
//
res.m_nothingtocommit_message_flag = true;
//
}
return
res;
}
bool
status_list_wrapper::has_untracked_header
()
const
{
return
m_untracked_header_flag;
}
bool
status_list_wrapper::has_tobecommited_header
()
const
{
return
m_tobecommited_header_flag;
}
bool
status_list_wrapper::has_ignored_header
()
const
{
return
m_ignored_header_flag;
}
bool
status_list_wrapper::has_notstagged_header
()
const
{
return
m_notstagged_header_flag;
}
bool
status_list_wrapper::has_unmerged_header
()
const
{
return
m_unmerged_header_flag;
}
bool
status_list_wrapper::has_nothingtocommit_message
()
const
{
return
m_nothingtocommit_message_flag;
}
auto
status_list_wrapper::get_entry_list
(
git_status_t
status)
const
->
const
status_entry_list&
{
if
(
auto
search = m_entries.
find
(status); search != m_entries.
end
())
{
return
search->
second
;
}
else
{
return
m_empty;
}
}
Back
|
FazBrowse Home
|
New Git URL