| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Walker |
| 2 |
|
| |
| 3 |
|
| SV * |
| 4 |
|
| create(class, repo) |
| 5 |
|
| SV *class |
| 6 |
|
| SV *repo |
| 7 |
|
| |
| 8 |
|
| PREINIT: |
| 9 |
|
| int rc; |
| 10 |
|
| |
| 11 |
|
| Repository repo_ptr; |
| 12 |
|
| Walker walk; |
| 13 |
|
| |
| 14 |
|
| CODE: |
| 15 |
2 |
| repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
| 16 |
2 |
| rc = git_revwalk_new(&walk, repo_ptr -> repository); |
| 17 |
2 |
| git_check_error(rc); |
| 18 |
|
| |
| 19 |
4 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 20 |
|
| RETVAL, SvPVbyte_nolen(class), walk, SvRV(repo) |
| 21 |
|
| ); |
| 22 |
|
| |
| 23 |
|
| OUTPUT: RETVAL |
| 24 |
|
| |
| 25 |
|
| void |
| 26 |
|
| sorting(self, order) |
| 27 |
|
| Walker self |
| 28 |
|
| SV *order |
| 29 |
|
| |
| 30 |
|
| PREINIT: |
| 31 |
5 |
| size_t i = 0; |
| 32 |
|
| AV *order_list; |
| 33 |
|
| |
| 34 |
|
| SV **entry; |
| 35 |
5 |
| unsigned int mode = GIT_SORT_NONE; |
| 36 |
|
| |
| 37 |
|
| CODE: |
| 38 |
5 |
| order_list = git_ensure_av(order, "order"); |
| 39 |
9 |
▶ | while ((entry = av_fetch(order_list, i++, 0))) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((entry = av_fetch(order_list, i++, 0))) { |
6 |
3 |
9 |
|
| 40 |
6 |
▶ | if (SvPOK(*entry)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvPOK(*entry)) { |
5 |
1 |
6 |
|
| 41 |
5 |
| const char *mode_str = SvPVbyte_nolen(*entry); |
| 42 |
|
| |
| 43 |
5 |
▶ | if (strcmp(mode_str, "none") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp(mode_str, "none") == 0) |
1 |
4 |
5 |
|
| 44 |
1 |
| mode = GIT_SORT_NONE; |
| 45 |
4 |
▶ | else if (strcmp(mode_str, "topological") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strcmp(mode_str, "topological") == 0) |
1 |
3 |
4 |
|
| 46 |
1 |
| mode |= GIT_SORT_TOPOLOGICAL; |
| 47 |
3 |
▶ | else if (strcmp(mode_str, "time") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strcmp(mode_str, "time") == 0) |
1 |
2 |
3 |
|
| 48 |
1 |
| mode |= GIT_SORT_TIME; |
| 49 |
2 |
▶ | else if (strcmp(mode_str, "reverse") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strcmp(mode_str, "reverse") == 0) |
1 |
1 |
2 |
|
| 50 |
1 |
| mode |= GIT_SORT_REVERSE; |
| 51 |
|
| else |
| 52 |
1 |
| croak_usage("Invalid 'order' value"); |
| 53 |
|
| } else |
| 54 |
1 |
| croak_usage("Invalid type for 'order' value"); |
| 55 |
|
| } |
| 56 |
|
| |
| 57 |
3 |
| git_revwalk_sorting(self, mode); |
| 58 |
|
| |
| 59 |
|
| void |
| 60 |
|
| push(self, commit) |
| 61 |
|
| Walker self |
| 62 |
|
| Commit commit |
| 63 |
|
| |
| 64 |
|
| PREINIT: |
| 65 |
|
| int rc; |
| 66 |
|
| |
| 67 |
|
| CODE: |
| 68 |
6 |
| rc = git_revwalk_push(self, git_commit_id(commit)); |
| 69 |
6 |
| git_check_error(rc); |
| 70 |
|
| |
| 71 |
|
| void |
| 72 |
|
| push_glob(self, glob) |
| 73 |
|
| Walker self |
| 74 |
|
| const char* glob |
| 75 |
|
| |
| 76 |
|
| PREINIT: |
| 77 |
|
| int rc; |
| 78 |
|
| |
| 79 |
|
| CODE: |
| 80 |
1 |
| rc = git_revwalk_push_glob(self, glob); |
| 81 |
1 |
| git_check_error(rc); |
| 82 |
|
| |
| 83 |
|
| void |
| 84 |
|
| push_ref(self, ref) |
| 85 |
|
| Walker self |
| 86 |
|
| const char* ref |
| 87 |
|
| |
| 88 |
|
| PREINIT: |
| 89 |
|
| int rc; |
| 90 |
|
| |
| 91 |
|
| CODE: |
| 92 |
1 |
| rc = git_revwalk_push_ref(self, ref); |
| 93 |
1 |
| git_check_error(rc); |
| 94 |
|
| |
| 95 |
|
| void |
| 96 |
|
| push_head(self) |
| 97 |
|
| Walker self |
| 98 |
|
| |
| 99 |
|
| PREINIT: |
| 100 |
|
| int rc; |
| 101 |
|
| |
| 102 |
|
| CODE: |
| 103 |
7 |
| rc = git_revwalk_push_head(self); |
| 104 |
7 |
| git_check_error(rc); |
| 105 |
|
| |
| 106 |
|
| void |
| 107 |
|
| push_range(self, ...) |
| 108 |
|
| SV *self |
| 109 |
|
| |
| 110 |
|
| PROTOTYPE: $;@ |
| 111 |
|
| PREINIT: |
| 112 |
8 |
| int rc = 0; |
| 113 |
|
| |
| 114 |
|
| git_repository *repo; |
| 115 |
|
| Walker walk; |
| 116 |
|
| |
| 117 |
8 |
| char *range = NULL; |
| 118 |
|
| |
| 119 |
|
| CODE: |
| 120 |
8 |
| walk = GIT_SV_TO_PTR(Walker, self); |
| 121 |
8 |
| repo = git_revwalk_repository(walk); |
| 122 |
|
| |
| 123 |
8 |
▶ | if (items == 3) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items == 3) { |
4 |
4 |
8 |
|
| 124 |
4 |
| size_t buffer_size = 2 * GIT_OID_HEXSZ + 2 + 1; |
| 125 |
|
| git_oid start, end; |
| 126 |
|
| |
| 127 |
4 |
▶ | if (git_sv_to_commitish(repo, ST(1), &start) == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (git_sv_to_commitish(repo, ST(1), &start) == NULL) |
1 |
3 |
4 |
|
| 128 |
1 |
| croak_resolve("Could not resolve 'start' to a commit id"); |
| 129 |
3 |
▶ | if (git_sv_to_commitish(repo, ST(2), &end) == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (git_sv_to_commitish(repo, ST(2), &end) == NULL) |
1 |
2 |
3 |
|
| 130 |
1 |
| croak_resolve("Could not resolve 'end' to a commit id"); |
| 131 |
|
| |
| 132 |
2 |
| Newx(range, buffer_size, char); |
| 133 |
|
| |
| 134 |
2 |
| git_oid_tostr(range, GIT_OID_HEXSZ + 1, &start); |
| 135 |
2 |
| strncpy(range + GIT_OID_HEXSZ, "..", buffer_size-GIT_OID_HEXSZ); |
| 136 |
2 |
| git_oid_tostr(range + GIT_OID_HEXSZ + 2, GIT_OID_HEXSZ + 1, &end); |
| 137 |
2 |
| rc = git_revwalk_push_range(walk, range); |
| 138 |
2 |
| Safefree(range); |
| 139 |
4 |
▶ | } else if (items == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (items == 2) { |
3 |
1 |
4 |
|
| 140 |
3 |
| range = (char *) git_ensure_pv(ST(1), "range"); |
| 141 |
3 |
| rc = git_revwalk_push_range(walk, range); |
| 142 |
|
| } else |
| 143 |
1 |
| croak_usage("'range' not provided"); |
| 144 |
|
| |
| 145 |
5 |
| git_check_error(rc); |
| 146 |
|
| |
| 147 |
|
| void |
| 148 |
|
| hide(self, commit) |
| 149 |
|
| Walker self |
| 150 |
|
| Commit commit |
| 151 |
|
| |
| 152 |
|
| PREINIT: |
| 153 |
|
| int rc; |
| 154 |
|
| |
| 155 |
|
| CODE: |
| 156 |
1 |
| rc = git_revwalk_hide(self, git_commit_id(commit)); |
| 157 |
1 |
| git_check_error(rc); |
| 158 |
|
| |
| 159 |
|
| void |
| 160 |
|
| hide_glob(self, glob) |
| 161 |
|
| Walker self |
| 162 |
|
| char* glob |
| 163 |
|
| |
| 164 |
|
| PREINIT: |
| 165 |
|
| int rc; |
| 166 |
|
| |
| 167 |
|
| CODE: |
| 168 |
1 |
| rc = git_revwalk_hide_glob(self, glob); |
| 169 |
1 |
| git_check_error(rc); |
| 170 |
|
| |
| 171 |
|
| void |
| 172 |
|
| hide_ref(self, ref) |
| 173 |
|
| Walker self |
| 174 |
|
| char* ref |
| 175 |
|
| |
| 176 |
|
| PREINIT: |
| 177 |
|
| int rc; |
| 178 |
|
| |
| 179 |
|
| CODE: |
| 180 |
2 |
| rc = git_revwalk_hide_ref(self, ref); |
| 181 |
2 |
| git_check_error(rc); |
| 182 |
|
| |
| 183 |
|
| void |
| 184 |
|
| hide_head(self) |
| 185 |
|
| Walker self |
| 186 |
|
| |
| 187 |
|
| PREINIT: |
| 188 |
|
| int rc; |
| 189 |
|
| |
| 190 |
|
| CODE: |
| 191 |
1 |
| rc = git_revwalk_hide_head(self); |
| 192 |
1 |
| git_check_error(rc); |
| 193 |
|
| |
| 194 |
|
| SV * |
| 195 |
|
| next(self) |
| 196 |
|
| SV *self |
| 197 |
|
| |
| 198 |
|
| PREINIT: |
| 199 |
|
| int rc; |
| 200 |
|
| |
| 201 |
|
| SV *repo; |
| 202 |
|
| |
| 203 |
|
| Walker walk; |
| 204 |
|
| |
| 205 |
|
| git_oid oid; |
| 206 |
37 |
| Commit commit = NULL; |
| 207 |
|
| |
| 208 |
|
| CODE: |
| 209 |
37 |
| repo = GIT_SV_TO_MAGIC(self); |
| 210 |
37 |
| walk = GIT_SV_TO_PTR(Walker, self); |
| 211 |
|
| |
| 212 |
37 |
| rc = git_revwalk_next(&oid, walk); |
| 213 |
37 |
▶ | if (rc == GIT_ITEROVER) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == GIT_ITEROVER) |
13 |
24 |
37 |
|
| 214 |
13 |
| XSRETURN_UNDEF; |
| 215 |
24 |
| git_check_error(rc); |
| 216 |
|
| |
| 217 |
24 |
| rc = git_commit_lookup(&commit, git_revwalk_repository(walk), &oid); |
| 218 |
24 |
| git_check_error(rc); |
| 219 |
|
| |
| 220 |
24 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 221 |
|
| RETVAL, "Git::Raw::Commit", commit, repo |
| 222 |
|
| ); |
| 223 |
|
| |
| 224 |
|
| OUTPUT: RETVAL |
| 225 |
|
| |
| 226 |
|
| void |
| 227 |
|
| all(self) |
| 228 |
|
| SV *self |
| 229 |
|
| |
| 230 |
|
| PREINIT: |
| 231 |
|
| int ctx; |
| 232 |
|
| |
| 233 |
|
| PPCODE: |
| 234 |
3 |
| ctx = GIMME_V; |
| 235 |
|
| |
| 236 |
3 |
▶ | if (ctx != G_VOID) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx != G_VOID) { |
2 |
1 |
3 |
|
| 237 |
|
| int rc; |
| 238 |
|
| git_oid oid; |
| 239 |
2 |
| size_t count = 0; |
| 240 |
2 |
| SV *repo = GIT_SV_TO_MAGIC(self); |
| 241 |
2 |
| Walker walk = GIT_SV_TO_PTR(Walker, self); |
| 242 |
|
| |
| 243 |
8 |
▶ | while ((rc = git_revwalk_next(&oid, walk)) != GIT_ITEROVER) { |
Branch: 1 branch
| Branch | True | False | Total |
| while ((rc = git_revwalk_next(&oid, walk)) != GIT_ITEROVER) { |
6 |
2 |
8 |
|
| 244 |
6 |
| git_check_error(rc); |
| 245 |
|
| |
| 246 |
6 |
▶ | if (ctx == G_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx == G_ARRAY) { |
3 |
3 |
6 |
|
| 247 |
3 |
| Commit commit = NULL; |
| 248 |
|
| SV *tmp; |
| 249 |
|
| |
| 250 |
3 |
| rc = git_commit_lookup(&commit, git_revwalk_repository(walk), &oid); |
| 251 |
3 |
| git_check_error(rc); |
| 252 |
|
| |
| 253 |
3 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 254 |
|
| tmp, "Git::Raw::Commit", commit, repo |
| 255 |
|
| ); |
| 256 |
|
| |
| 257 |
3 |
▶ | mXPUSHs(tmp); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(tmp); |
0 |
3 |
3 |
|
| 258 |
|
| } |
| 259 |
|
| |
| 260 |
6 |
| ++count; |
| 261 |
|
| } |
| 262 |
|
| |
| 263 |
2 |
▶ | if (ctx == G_ARRAY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx == G_ARRAY) { |
1 |
1 |
2 |
|
| 264 |
1 |
| XSRETURN((int) count); |
| 265 |
|
| } else { |
| 266 |
1 |
▶ | mXPUSHs(newSViv((int) count)); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(newSViv((int) count)); |
0 |
1 |
1 |
|
| 267 |
1 |
| XSRETURN(1); |
| 268 |
|
| } |
| 269 |
|
| } else |
| 270 |
1 |
| XSRETURN_EMPTY; |
| 271 |
|
| |
| 272 |
|
| void |
| 273 |
|
| reset(self) |
| 274 |
|
| Walker self |
| 275 |
|
| |
| 276 |
|
| CODE: |
| 277 |
9 |
| git_revwalk_reset(self); |
| 278 |
|
| |
| 279 |
|
| void |
| 280 |
|
| DESTROY(self) |
| 281 |
|
| SV *self |
| 282 |
|
| |
| 283 |
|
| CODE: |
| 284 |
2 |
| git_revwalk_free(GIT_SV_TO_PTR(Walker, self)); |
| 285 |
2 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |