line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODULE = Git::Raw PACKAGE = Git::Raw::Graph |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
void |
4
|
|
|
|
|
|
|
ahead(class, repo, local, upstream) |
5
|
|
|
|
|
|
|
SV *class |
6
|
|
|
|
|
|
|
SV *repo |
7
|
|
|
|
|
|
|
SV *local |
8
|
|
|
|
|
|
|
SV *upstream |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
PREINIT: |
11
|
|
|
|
|
|
|
int ctx; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Repository repo_ptr; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
size_t ahead, behind; |
16
|
|
|
|
|
|
|
git_oid local_id, upstream_id; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
PPCODE: |
19
|
5
|
50
|
|
|
|
|
ctx = GIMME_V; |
20
|
|
|
|
|
|
|
|
21
|
5
|
100
|
|
|
|
|
if (ctx != G_VOID) { |
22
|
|
|
|
|
|
|
int rc; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
|
repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
25
|
4
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo_ptr -> repository, local, &local_id) == NULL) |
26
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'local' to a commit id"); |
27
|
|
|
|
|
|
|
|
28
|
3
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo_ptr -> repository, upstream, &upstream_id) == NULL) |
29
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'upstream' to a commit id"); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
|
rc = git_graph_ahead_behind( |
32
|
|
|
|
|
|
|
&ahead, &behind, |
33
|
|
|
|
|
|
|
repo_ptr -> repository, |
34
|
|
|
|
|
|
|
&local_id, &upstream_id |
35
|
|
|
|
|
|
|
); |
36
|
2
|
|
|
|
|
|
git_check_error(rc); |
37
|
|
|
|
|
|
|
|
38
|
2
|
100
|
|
|
|
|
if (ctx == G_ARRAY) { |
39
|
1
|
|
|
|
|
|
git_revwalk *walker = NULL; |
40
|
|
|
|
|
|
|
size_t i; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
|
rc = git_revwalk_new(&walker, repo_ptr -> repository); |
43
|
1
|
|
|
|
|
|
git_check_error(rc); |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
|
rc = git_revwalk_push(walker, &local_id); |
46
|
1
|
|
|
|
|
|
git_check_error(rc); |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
|
git_revwalk_sorting(walker, GIT_SORT_TOPOLOGICAL); |
49
|
3
|
100
|
|
|
|
|
for (i = 0; i < ahead; ++i) { |
50
|
|
|
|
|
|
|
git_oid commit_id; |
51
|
|
|
|
|
|
|
Commit commit; |
52
|
2
|
|
|
|
|
|
SV *c = NULL; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
|
rc = git_revwalk_next(&commit_id, walker); |
55
|
2
|
|
|
|
|
|
git_check_error(rc); |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
|
rc = git_commit_lookup( |
58
|
|
|
|
|
|
|
&commit, repo_ptr -> repository, |
59
|
|
|
|
|
|
|
&commit_id |
60
|
|
|
|
|
|
|
); |
61
|
2
|
|
|
|
|
|
git_check_error(rc); |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
|
GIT_NEW_OBJ_WITH_MAGIC( |
64
|
|
|
|
|
|
|
c, "Git::Raw::Commit", commit, SvRV(repo) |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
|
mXPUSHs(c); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
|
git_revwalk_free(walker); |
71
|
1
|
|
|
|
|
|
XSRETURN((int) ahead); |
72
|
|
|
|
|
|
|
} else { |
73
|
1
|
50
|
|
|
|
|
mXPUSHs(newSViv((int) ahead)); |
74
|
1
|
|
|
|
|
|
XSRETURN(1); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} else |
77
|
3
|
|
|
|
|
|
XSRETURN_EMPTY; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
void |
80
|
|
|
|
|
|
|
behind(class, repo, local, upstream) |
81
|
|
|
|
|
|
|
SV *class |
82
|
|
|
|
|
|
|
SV *repo |
83
|
|
|
|
|
|
|
SV *local |
84
|
|
|
|
|
|
|
SV *upstream |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
PREINIT: |
87
|
|
|
|
|
|
|
int ctx; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Repository repo_ptr; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
size_t ahead, behind; |
92
|
|
|
|
|
|
|
git_oid local_id, upstream_id; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
PPCODE: |
95
|
5
|
50
|
|
|
|
|
ctx = GIMME_V; |
96
|
|
|
|
|
|
|
|
97
|
5
|
100
|
|
|
|
|
if (ctx != G_VOID) { |
98
|
|
|
|
|
|
|
int rc; |
99
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
|
repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
101
|
4
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo_ptr -> repository, local, &local_id) == NULL) |
102
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'local' to a commit id"); |
103
|
|
|
|
|
|
|
|
104
|
3
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo_ptr -> repository, upstream, &upstream_id) == NULL) |
105
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'upstream' to a commit id"); |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
|
rc = git_graph_ahead_behind( |
108
|
|
|
|
|
|
|
&ahead, &behind, |
109
|
|
|
|
|
|
|
repo_ptr -> repository, |
110
|
|
|
|
|
|
|
&local_id, &upstream_id |
111
|
|
|
|
|
|
|
); |
112
|
2
|
|
|
|
|
|
git_check_error(rc); |
113
|
|
|
|
|
|
|
|
114
|
2
|
100
|
|
|
|
|
if (ctx == G_ARRAY) { |
115
|
1
|
|
|
|
|
|
git_revwalk *walker = NULL; |
116
|
|
|
|
|
|
|
size_t i; |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
|
rc = git_revwalk_new(&walker, repo_ptr -> repository); |
119
|
1
|
|
|
|
|
|
git_check_error(rc); |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
|
rc = git_revwalk_push(walker, &upstream_id); |
122
|
1
|
|
|
|
|
|
git_check_error(rc); |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
|
git_revwalk_sorting(walker, GIT_SORT_TOPOLOGICAL); |
125
|
3
|
100
|
|
|
|
|
for (i = 0; i < behind; ++i) { |
126
|
|
|
|
|
|
|
git_oid commit_id; |
127
|
|
|
|
|
|
|
Commit commit; |
128
|
2
|
|
|
|
|
|
SV *c = NULL; |
129
|
|
|
|
|
|
|
|
130
|
2
|
|
|
|
|
|
rc = git_revwalk_next(&commit_id, walker); |
131
|
2
|
|
|
|
|
|
git_check_error(rc); |
132
|
|
|
|
|
|
|
|
133
|
2
|
|
|
|
|
|
rc = git_commit_lookup( |
134
|
|
|
|
|
|
|
&commit, repo_ptr -> repository, |
135
|
|
|
|
|
|
|
&commit_id |
136
|
|
|
|
|
|
|
); |
137
|
2
|
|
|
|
|
|
git_check_error(rc); |
138
|
|
|
|
|
|
|
|
139
|
2
|
|
|
|
|
|
GIT_NEW_OBJ_WITH_MAGIC( |
140
|
|
|
|
|
|
|
c, "Git::Raw::Commit", commit, SvRV(repo) |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
|
143
|
2
|
50
|
|
|
|
|
mXPUSHs(c); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
1
|
|
|
|
|
|
git_revwalk_free(walker); |
147
|
1
|
|
|
|
|
|
XSRETURN((int) behind); |
148
|
|
|
|
|
|
|
} else { |
149
|
1
|
50
|
|
|
|
|
mXPUSHs(newSViv((int) behind)); |
150
|
1
|
|
|
|
|
|
XSRETURN(1); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} else |
153
|
3
|
|
|
|
|
|
XSRETURN_EMPTY; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
SV * |
156
|
|
|
|
|
|
|
ahead_behind(class, repo, local, upstream) |
157
|
|
|
|
|
|
|
SV *class |
158
|
|
|
|
|
|
|
SV *repo |
159
|
|
|
|
|
|
|
SV *local |
160
|
|
|
|
|
|
|
SV *upstream |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
PREINIT: |
163
|
|
|
|
|
|
|
int rc; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Repository repo_ptr; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
size_t i, ahead, behind; |
168
|
|
|
|
|
|
|
git_oid local_id, upstream_id; |
169
|
|
|
|
|
|
|
|
170
|
4
|
|
|
|
|
|
git_revwalk *walker = NULL; |
171
|
4
|
|
|
|
|
|
HV *r = NULL; |
172
|
4
|
|
|
|
|
|
AV *a = NULL, *b = NULL; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
CODE: |
175
|
4
|
|
|
|
|
|
repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
176
|
4
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo_ptr -> repository, local, &local_id) == NULL) |
177
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'local' to a commit id"); |
178
|
|
|
|
|
|
|
|
179
|
3
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo_ptr -> repository, upstream, &upstream_id) == NULL) |
180
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'upstream' to a commit id"); |
181
|
|
|
|
|
|
|
|
182
|
2
|
|
|
|
|
|
rc = git_graph_ahead_behind( |
183
|
|
|
|
|
|
|
&ahead, &behind, |
184
|
|
|
|
|
|
|
repo_ptr -> repository, |
185
|
|
|
|
|
|
|
&local_id, &upstream_id |
186
|
|
|
|
|
|
|
); |
187
|
2
|
|
|
|
|
|
git_check_error(rc); |
188
|
|
|
|
|
|
|
|
189
|
2
|
|
|
|
|
|
r = newHV(); |
190
|
2
|
100
|
|
|
|
|
if (ahead > 0 || behind > 0) { |
|
|
50
|
|
|
|
|
|
191
|
|
|
|
|
|
|
git_oid commit_id; |
192
|
|
|
|
|
|
|
Commit commit; |
193
|
2
|
|
|
|
|
|
SV *c = NULL; |
194
|
|
|
|
|
|
|
|
195
|
2
|
|
|
|
|
|
rc = git_revwalk_new(&walker, repo_ptr -> repository); |
196
|
2
|
|
|
|
|
|
git_check_error(rc); |
197
|
|
|
|
|
|
|
|
198
|
2
|
100
|
|
|
|
|
if (ahead > 0) { |
199
|
1
|
|
|
|
|
|
git_revwalk_reset(walker); |
200
|
1
|
|
|
|
|
|
git_revwalk_sorting(walker, GIT_SORT_TOPOLOGICAL); |
201
|
1
|
|
|
|
|
|
rc = git_revwalk_push(walker, &local_id); |
202
|
1
|
|
|
|
|
|
git_check_error(rc); |
203
|
|
|
|
|
|
|
|
204
|
1
|
|
|
|
|
|
a = newAV(); |
205
|
3
|
100
|
|
|
|
|
for (i = 0; i < ahead; ++i) { |
206
|
2
|
|
|
|
|
|
rc = git_revwalk_next(&commit_id, walker); |
207
|
2
|
|
|
|
|
|
git_check_error(rc); |
208
|
|
|
|
|
|
|
|
209
|
2
|
|
|
|
|
|
rc = git_commit_lookup( |
210
|
|
|
|
|
|
|
&commit, repo_ptr -> repository, |
211
|
|
|
|
|
|
|
&commit_id |
212
|
|
|
|
|
|
|
); |
213
|
2
|
|
|
|
|
|
git_check_error(rc); |
214
|
|
|
|
|
|
|
|
215
|
2
|
|
|
|
|
|
GIT_NEW_OBJ_WITH_MAGIC( |
216
|
|
|
|
|
|
|
c, "Git::Raw::Commit", commit, SvRV(repo) |
217
|
|
|
|
|
|
|
); |
218
|
2
|
|
|
|
|
|
av_push(a, c); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
1
|
|
|
|
|
|
hv_stores(r, "ahead", newRV_noinc((SV *) a)); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
2
|
100
|
|
|
|
|
if (behind > 0) { |
225
|
1
|
|
|
|
|
|
git_revwalk_reset(walker); |
226
|
1
|
|
|
|
|
|
git_revwalk_sorting(walker, GIT_SORT_TOPOLOGICAL); |
227
|
1
|
|
|
|
|
|
rc = git_revwalk_push(walker, &upstream_id); |
228
|
1
|
|
|
|
|
|
git_check_error(rc); |
229
|
|
|
|
|
|
|
|
230
|
1
|
|
|
|
|
|
b = newAV(); |
231
|
3
|
100
|
|
|
|
|
for (i = 0; i < behind; ++i) { |
232
|
2
|
|
|
|
|
|
rc = git_revwalk_next(&commit_id, walker); |
233
|
2
|
|
|
|
|
|
git_check_error(rc); |
234
|
|
|
|
|
|
|
|
235
|
2
|
|
|
|
|
|
rc = git_commit_lookup( |
236
|
|
|
|
|
|
|
&commit, repo_ptr -> repository, |
237
|
|
|
|
|
|
|
&commit_id |
238
|
|
|
|
|
|
|
); |
239
|
2
|
|
|
|
|
|
git_check_error(rc); |
240
|
|
|
|
|
|
|
|
241
|
2
|
|
|
|
|
|
GIT_NEW_OBJ_WITH_MAGIC( |
242
|
|
|
|
|
|
|
c, "Git::Raw::Commit", commit, SvRV(repo) |
243
|
|
|
|
|
|
|
); |
244
|
2
|
|
|
|
|
|
av_push(b, c); |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
2
|
|
|
|
|
|
hv_stores(r, "behind", newRV_noinc((SV *) b)); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
2
|
|
|
|
|
|
git_revwalk_free(walker); |
252
|
2
|
|
|
|
|
|
RETVAL = newRV_noinc((SV *) r); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
OUTPUT: RETVAL |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
SV * |
257
|
|
|
|
|
|
|
is_descendant_of(class, repo, commitish, ancestor) |
258
|
|
|
|
|
|
|
SV *class |
259
|
|
|
|
|
|
|
Repository repo |
260
|
|
|
|
|
|
|
SV *commitish |
261
|
|
|
|
|
|
|
SV *ancestor |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
PREINIT: |
264
|
23
|
|
|
|
|
|
int result = 0; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
git_oid commitish_id, ancestor_id; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
CODE: |
269
|
23
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo -> repository, commitish, &commitish_id) == NULL) |
270
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'commitish' to a commit id"); |
271
|
|
|
|
|
|
|
|
272
|
22
|
100
|
|
|
|
|
if (git_sv_to_commitish(repo -> repository, ancestor, &ancestor_id) == NULL) |
273
|
1
|
|
|
|
|
|
croak_resolve("Could not resolve 'ancestor' to a commit id"); |
274
|
|
|
|
|
|
|
|
275
|
21
|
|
|
|
|
|
result = git_graph_descendant_of(repo -> repository, &commitish_id, &ancestor_id); |
276
|
21
|
100
|
|
|
|
|
if (result < 0) |
277
|
|
|
|
|
|
|
{ |
278
|
1
|
|
|
|
|
|
git_check_error(result); |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
20
|
|
|
|
|
|
RETVAL = newSViv(result); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
OUTPUT: RETVAL |