| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Patch |
| 2 |
|
| |
| 3 |
|
| SV * |
| 4 |
|
| buffer(self) |
| 5 |
|
| Patch self |
| 6 |
|
| |
| 7 |
|
| PREINIT: |
| 8 |
|
| int rc; |
| 9 |
|
| |
| 10 |
7 |
| git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); |
| 11 |
|
| |
| 12 |
|
| CODE: |
| 13 |
7 |
| rc = git_patch_to_buf(&buf, self); |
| 14 |
7 |
| git_check_error(rc); |
| 15 |
|
| |
| 16 |
7 |
| RETVAL = newSVpv(buf.ptr, buf.size); |
| 17 |
|
| |
| 18 |
7 |
| git_buf_dispose(&buf); |
| 19 |
|
| |
| 20 |
|
| OUTPUT: RETVAL |
| 21 |
|
| |
| 22 |
|
| SV * |
| 23 |
|
| hunk_count(self) |
| 24 |
|
| Patch self |
| 25 |
|
| |
| 26 |
|
| CODE: |
| 27 |
2 |
| RETVAL = newSVuv(git_patch_num_hunks(self)); |
| 28 |
|
| |
| 29 |
|
| OUTPUT: RETVAL |
| 30 |
|
| |
| 31 |
|
| void |
| 32 |
|
| hunks(self, ...) |
| 33 |
|
| SV *self |
| 34 |
|
| |
| 35 |
|
| PROTOTYPE: $;$ |
| 36 |
|
| |
| 37 |
|
| PREINIT: |
| 38 |
8 |
| size_t start = 0, end, num_hunks; |
| 39 |
|
| |
| 40 |
|
| PPCODE: |
| 41 |
8 |
| num_hunks = git_patch_num_hunks(GIT_SV_TO_PTR(Patch, self)); |
| 42 |
|
| |
| 43 |
8 |
▶ | if (items == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items == 2) { |
6 |
2 |
8 |
|
| 44 |
6 |
| SV *index = ST(1); |
| 45 |
|
| |
| 46 |
6 |
▶ | if (!SvIOK(index) || SvIV(index) < 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvIOK(index) || SvIV(index) < 0) |
4 |
2 |
6 |
| if (!SvIOK(index) || SvIV(index) < 0) |
0 |
4 |
4 |
|
| 47 |
2 |
| croak_usage("Invalid type for 'index'"); |
| 48 |
|
| |
| 49 |
4 |
| start = SvUV(index); |
| 50 |
4 |
▶ | if (start >= num_hunks) |
Branch: 1 branch
| Branch | True | False | Total |
| if (start >= num_hunks) |
2 |
2 |
4 |
|
| 51 |
2 |
| croak_usage("index %" PRIuZ " out of range", start); |
| 52 |
|
| |
| 53 |
2 |
| num_hunks = 1; |
| 54 |
|
| } |
| 55 |
|
| |
| 56 |
4 |
| end = start + num_hunks; |
| 57 |
|
| |
| 58 |
8 |
▶ | for (; start < end; ++start) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (; start < end; ++start) { |
4 |
4 |
8 |
|
| 59 |
|
| SV *hunk; |
| 60 |
|
| const git_diff_hunk *h; |
| 61 |
|
| |
| 62 |
4 |
| int rc = git_patch_get_hunk( |
| 63 |
4 |
| &h, NULL, GIT_SV_TO_PTR(Patch, self), start |
| 64 |
|
| ); |
| 65 |
4 |
| git_check_error(rc); |
| 66 |
|
| |
| 67 |
4 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 68 |
|
| hunk, "Git::Raw::Diff::Hunk", |
| 69 |
|
| (Diff_Hunk) h, SvRV(self) |
| 70 |
|
| ); |
| 71 |
|
| |
| 72 |
4 |
▶ | mXPUSHs(hunk); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(hunk); |
0 |
4 |
4 |
|
| 73 |
|
| } |
| 74 |
|
| |
| 75 |
4 |
| XSRETURN(num_hunks); |
| 76 |
|
| |
| 77 |
|
| SV * |
| 78 |
|
| line_stats(self) |
| 79 |
|
| Patch self |
| 80 |
|
| |
| 81 |
|
| PREINIT: |
| 82 |
|
| int rc; |
| 83 |
|
| |
| 84 |
|
| size_t total_context, total_additions, total_deletions; |
| 85 |
|
| |
| 86 |
|
| HV *stats; |
| 87 |
|
| |
| 88 |
|
| CODE: |
| 89 |
2 |
| rc = git_patch_line_stats( |
| 90 |
|
| &total_context, &total_additions, &total_deletions, self |
| 91 |
|
| ); |
| 92 |
2 |
| git_check_error(rc); |
| 93 |
|
| |
| 94 |
2 |
| stats = newHV(); |
| 95 |
|
| |
| 96 |
2 |
| hv_stores(stats, "context", newSVuv(total_context)); |
| 97 |
2 |
| hv_stores(stats, "additions", newSVuv(total_additions)); |
| 98 |
2 |
| hv_stores(stats, "deletions", newSVuv(total_deletions)); |
| 99 |
|
| |
| 100 |
2 |
| RETVAL = newRV_noinc((SV *) stats); |
| 101 |
|
| |
| 102 |
|
| OUTPUT: RETVAL |
| 103 |
|
| |
| 104 |
|
| SV * |
| 105 |
|
| delta(self) |
| 106 |
|
| SV *self |
| 107 |
|
| |
| 108 |
|
| CODE: |
| 109 |
|
| const git_diff_delta *delta = |
| 110 |
3 |
| git_patch_get_delta(GIT_SV_TO_PTR(Patch, self) |
| 111 |
|
| ); |
| 112 |
|
| |
| 113 |
3 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 114 |
|
| RETVAL, "Git::Raw::Diff::Delta", |
| 115 |
|
| (Diff_Delta) delta, SvRV(self)); |
| 116 |
|
| |
| 117 |
|
| OUTPUT: RETVAL |
| 118 |
|
| |
| 119 |
|
| void |
| 120 |
|
| DESTROY(self) |
| 121 |
|
| SV *self |
| 122 |
|
| |
| 123 |
|
| CODE: |
| 124 |
10 |
| git_patch_free(GIT_SV_TO_PTR(Patch, self)); |
| 125 |
10 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |