| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Blame |
| 2 |
|
| |
| 3 |
|
| SV * |
| 4 |
|
| hunk_count(self) |
| 5 |
|
| Blame self |
| 6 |
|
| |
| 7 |
|
| CODE: |
| 8 |
2 |
| RETVAL = newSVuv(git_blame_get_hunk_count(self)); |
| 9 |
|
| |
| 10 |
|
| OUTPUT: RETVAL |
| 11 |
|
| |
| 12 |
|
| void |
| 13 |
|
| hunks(self, ...) |
| 14 |
|
| SV *self |
| 15 |
|
| |
| 16 |
|
| PROTOTYPE: $;$ |
| 17 |
|
| |
| 18 |
|
| PREINIT: |
| 19 |
5 |
| size_t start = 0, end, num_hunks; |
| 20 |
|
| |
| 21 |
|
| PPCODE: |
| 22 |
5 |
| num_hunks = git_blame_get_hunk_count(GIT_SV_TO_PTR(Blame, self)); |
| 23 |
|
| |
| 24 |
5 |
▶ | if (items == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items == 2) { |
4 |
1 |
5 |
|
| 25 |
4 |
| SV *index = ST(1); |
| 26 |
|
| |
| 27 |
4 |
▶ | if (!SvIOK(index) || SvIV(index) < 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvIOK(index) || SvIV(index) < 0) |
3 |
1 |
4 |
| if (!SvIOK(index) || SvIV(index) < 0) |
0 |
3 |
3 |
|
| 28 |
1 |
| croak_usage("Invalid type for 'index'"); |
| 29 |
|
| |
| 30 |
3 |
| start = SvUV(index); |
| 31 |
3 |
▶ | if (start >= num_hunks) |
Branch: 1 branch
| Branch | True | False | Total |
| if (start >= num_hunks) |
1 |
2 |
3 |
|
| 32 |
1 |
| croak_usage("index %" PRIuZ " out of range", start); |
| 33 |
|
| |
| 34 |
2 |
| num_hunks = 1; |
| 35 |
|
| } |
| 36 |
|
| |
| 37 |
3 |
| end = start + num_hunks; |
| 38 |
|
| |
| 39 |
8 |
▶ | for (; start < end; ++start) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (; start < end; ++start) { |
5 |
3 |
8 |
|
| 40 |
|
| SV *hunk; |
| 41 |
|
| |
| 42 |
|
| const git_blame_hunk *h = |
| 43 |
5 |
| git_blame_get_hunk_byindex(GIT_SV_TO_PTR(Blame, self), |
| 44 |
|
| start); |
| 45 |
|
| |
| 46 |
5 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 47 |
|
| hunk, "Git::Raw::Blame::Hunk", |
| 48 |
|
| (Blame_Hunk) h, SvRV(self) |
| 49 |
|
| ); |
| 50 |
|
| |
| 51 |
5 |
▶ | mXPUSHs(hunk); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(hunk); |
0 |
5 |
5 |
|
| 52 |
|
| } |
| 53 |
|
| |
| 54 |
3 |
| XSRETURN(num_hunks); |
| 55 |
|
| |
| 56 |
|
| SV * |
| 57 |
|
| buffer(self, buffer) |
| 58 |
|
| SV *self |
| 59 |
|
| SV *buffer |
| 60 |
|
| |
| 61 |
|
| PREINIT: |
| 62 |
|
| int rc; |
| 63 |
|
| |
| 64 |
|
| Blame blame; |
| 65 |
|
| |
| 66 |
|
| const char *text; |
| 67 |
|
| STRLEN len; |
| 68 |
|
| |
| 69 |
|
| CODE: |
| 70 |
1 |
| text = git_ensure_pv_with_len(buffer, "buffer", &len); |
| 71 |
|
| |
| 72 |
1 |
| rc = git_blame_buffer( |
| 73 |
1 |
| &blame, GIT_SV_TO_PTR(Blame, self), |
| 74 |
|
| text, len); |
| 75 |
1 |
| git_check_error(rc); |
| 76 |
|
| |
| 77 |
1 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 78 |
|
| RETVAL, "Git::Raw::Blame", |
| 79 |
|
| blame, SvRV(self)); |
| 80 |
|
| OUTPUT: RETVAL |
| 81 |
|
| |
| 82 |
|
| SV * |
| 83 |
|
| line(self, line_no) |
| 84 |
|
| SV *self |
| 85 |
|
| size_t line_no |
| 86 |
|
| |
| 87 |
|
| PREINIT: |
| 88 |
|
| const git_blame_hunk *h; |
| 89 |
|
| |
| 90 |
|
| CODE: |
| 91 |
2 |
▶ | if ((h = git_blame_get_hunk_byline( |
Branch: 1 branch
| Branch | True | False | Total |
| if ((h = git_blame_get_hunk_byline( |
1 |
1 |
2 |
|
| 92 |
2 |
| GIT_SV_TO_PTR(Blame, self), line_no))) { |
| 93 |
|
| |
| 94 |
1 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 95 |
|
| RETVAL, "Git::Raw::Blame::Hunk", |
| 96 |
|
| (Blame_Hunk) h, SvRV(self) |
| 97 |
|
| ); |
| 98 |
|
| } else { |
| 99 |
1 |
| RETVAL = &PL_sv_undef; |
| 100 |
|
| } |
| 101 |
|
| |
| 102 |
|
| OUTPUT: RETVAL |
| 103 |
|
| |
| 104 |
|
| void |
| 105 |
|
| DESTROY(self) |
| 106 |
|
| SV *self |
| 107 |
|
| |
| 108 |
|
| CODE: |
| 109 |
2 |
| git_blame_free(GIT_SV_TO_PTR(Blame, self)); |
| 110 |
2 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |