| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Packbuilder |
| 2 |
|
| |
| 3 |
|
| INCLUDE: const-xs-packbuilder.inc |
| 4 |
|
| |
| 5 |
|
| SV * |
| 6 |
|
| new(class, repo) |
| 7 |
|
| SV *class |
| 8 |
|
| SV *repo |
| 9 |
|
| |
| 10 |
|
| PREINIT: |
| 11 |
|
| int rc; |
| 12 |
|
| |
| 13 |
|
| Repository repo_ptr; |
| 14 |
|
| Packbuilder pb; |
| 15 |
|
| |
| 16 |
|
| CODE: |
| 17 |
2 |
| repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
| 18 |
|
| |
| 19 |
2 |
| Newxz(pb, 1, git_raw_packbuilder); |
| 20 |
|
| |
| 21 |
2 |
| rc = git_packbuilder_new(&pb -> packbuilder, repo_ptr -> repository); |
| 22 |
2 |
| git_check_error(rc); |
| 23 |
|
| |
| 24 |
2 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 25 |
|
| RETVAL, "Git::Raw::Packbuilder", pb, SvRV(repo) |
| 26 |
|
| ); |
| 27 |
|
| |
| 28 |
|
| OUTPUT: RETVAL |
| 29 |
|
| |
| 30 |
|
| void |
| 31 |
|
| insert(self, object, recursive=&PL_sv_yes) |
| 32 |
|
| Packbuilder self |
| 33 |
|
| SV *object |
| 34 |
|
| SV *recursive |
| 35 |
|
| |
| 36 |
|
| PREINIT: |
| 37 |
5 |
| int rc = GIT_OK; |
| 38 |
|
| |
| 39 |
|
| CODE: |
| 40 |
5 |
▶ | if (!sv_isobject(object)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!sv_isobject(object)) |
1 |
4 |
5 |
|
| 41 |
1 |
| croak_usage("Invalid type for 'object', expected an object"); |
| 42 |
|
| |
| 43 |
4 |
▶ | if (sv_derived_from(object, "Git::Raw::Walker")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(object, "Git::Raw::Walker")) { |
1 |
3 |
4 |
|
| 44 |
1 |
| Walker walker = GIT_SV_TO_PTR(Walker, object); |
| 45 |
1 |
| rc = git_packbuilder_insert_walk(self -> packbuilder, walker); |
| 46 |
|
| } else { |
| 47 |
3 |
| git_object *o = git_sv_to_obj(object); |
| 48 |
3 |
▶ | if (o == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (o == NULL) |
1 |
2 |
3 |
|
| 49 |
1 |
| croak_usage("Unsupported object type"); |
| 50 |
|
| |
| 51 |
2 |
▶ | if (SvTRUE(recursive)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTRUE(recursive)) |
1 |
1 |
2 |
|
| 52 |
1 |
| rc = git_packbuilder_insert_recur(self -> packbuilder, git_object_id(o), NULL); |
| 53 |
|
| else |
| 54 |
1 |
| rc = git_packbuilder_insert(self -> packbuilder, git_object_id(o), NULL); |
| 55 |
|
| } |
| 56 |
|
| |
| 57 |
3 |
| git_check_error(rc); |
| 58 |
|
| |
| 59 |
|
| |
| 60 |
|
| void |
| 61 |
|
| write(self, path) |
| 62 |
|
| Packbuilder self |
| 63 |
|
| SV *path |
| 64 |
|
| |
| 65 |
|
| PREINIT: |
| 66 |
|
| int rc; |
| 67 |
|
| |
| 68 |
|
| const char *p; |
| 69 |
|
| static const char cbname[] = "transfer_progress"; |
| 70 |
|
| |
| 71 |
|
| CODE: |
| 72 |
2 |
| p = git_ensure_pv(path, "path"); |
| 73 |
|
| |
| 74 |
2 |
▶ | if (self -> callbacks && hv_exists(self -> callbacks, cbname, sizeof(cbname)-1)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (self -> callbacks && hv_exists(self -> callbacks, cbname, sizeof(cbname)-1)) |
1 |
1 |
2 |
| if (self -> callbacks && hv_exists(self -> callbacks, cbname, sizeof(cbname)-1)) |
1 |
0 |
1 |
|
| 75 |
1 |
| rc = git_packbuilder_write(self -> packbuilder, p, 0, |
| 76 |
1 |
| git_transfer_progress_cbb, self -> callbacks); |
| 77 |
|
| else |
| 78 |
1 |
| rc = git_packbuilder_write(self -> packbuilder, p, 0, |
| 79 |
|
| NULL, NULL); |
| 80 |
2 |
| git_check_error(rc); |
| 81 |
|
| |
| 82 |
|
| SV * |
| 83 |
|
| object_count(self) |
| 84 |
|
| Packbuilder self |
| 85 |
|
| |
| 86 |
|
| CODE: |
| 87 |
5 |
| size_t count = git_packbuilder_object_count(self -> packbuilder); |
| 88 |
5 |
| RETVAL = newSVuv(count); |
| 89 |
|
| |
| 90 |
|
| OUTPUT: RETVAL |
| 91 |
|
| |
| 92 |
|
| SV * |
| 93 |
|
| written(self) |
| 94 |
|
| Packbuilder self |
| 95 |
|
| |
| 96 |
|
| CODE: |
| 97 |
4 |
| size_t written = git_packbuilder_written(self -> packbuilder); |
| 98 |
4 |
| RETVAL = newSVuv(written); |
| 99 |
|
| |
| 100 |
|
| OUTPUT: RETVAL |
| 101 |
|
| |
| 102 |
|
| void |
| 103 |
|
| threads(self, count) |
| 104 |
|
| Packbuilder self |
| 105 |
|
| SV *count |
| 106 |
|
| |
| 107 |
|
| PREINIT: |
| 108 |
|
| I32 c; |
| 109 |
|
| CODE: |
| 110 |
2 |
| c = git_ensure_iv(count, "count"); |
| 111 |
2 |
▶ | if (c < 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (c < 0) |
1 |
1 |
2 |
|
| 112 |
1 |
| croak_usage("thread count should be >= 0"); |
| 113 |
|
| |
| 114 |
1 |
| git_packbuilder_set_threads(self -> packbuilder, (unsigned int)c); |
| 115 |
|
| |
| 116 |
|
| SV * |
| 117 |
|
| hash(self) |
| 118 |
|
| Packbuilder self |
| 119 |
|
| |
| 120 |
|
| CODE: |
| 121 |
2 |
| RETVAL = git_oid_to_sv(git_packbuilder_hash(self -> packbuilder)); |
| 122 |
|
| |
| 123 |
|
| OUTPUT: RETVAL |
| 124 |
|
| |
| 125 |
|
| void |
| 126 |
|
| callbacks(self, callbacks) |
| 127 |
|
| Packbuilder self |
| 128 |
|
| HV *callbacks |
| 129 |
|
| |
| 130 |
|
| PREINIT: |
| 131 |
|
| int rc; |
| 132 |
|
| SV *cb; |
| 133 |
|
| |
| 134 |
|
| CODE: |
| 135 |
1 |
▶ | if (!self -> callbacks) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!self -> callbacks) |
1 |
0 |
1 |
|
| 136 |
1 |
| self -> callbacks = newHV(); |
| 137 |
|
| |
| 138 |
1 |
▶ | if ((cb = get_callback_option(callbacks, "pack_progress"))) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((cb = get_callback_option(callbacks, "pack_progress"))) { |
1 |
0 |
1 |
|
| 139 |
1 |
| hv_stores(self -> callbacks, "pack_progress", cb); |
| 140 |
1 |
| rc = git_packbuilder_set_callbacks(self -> packbuilder, |
| 141 |
1 |
| git_packbuilder_progress_cbb, self -> callbacks); |
| 142 |
1 |
| git_check_error(rc); |
| 143 |
|
| } |
| 144 |
|
| |
| 145 |
1 |
▶ | if ((cb = get_callback_option(callbacks, "transfer_progress"))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((cb = get_callback_option(callbacks, "transfer_progress"))) |
1 |
0 |
1 |
|
| 146 |
1 |
| hv_stores(self -> callbacks, "transfer_progress", cb); |
| 147 |
|
| |
| 148 |
|
| void |
| 149 |
|
| DESTROY(self) |
| 150 |
|
| SV *self |
| 151 |
|
| |
| 152 |
|
| PREINIT: |
| 153 |
|
| Packbuilder pb; |
| 154 |
|
| |
| 155 |
|
| CODE: |
| 156 |
2 |
| pb = GIT_SV_TO_PTR(Packbuilder, self); |
| 157 |
2 |
▶ | if (pb -> callbacks) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pb -> callbacks) |
1 |
1 |
2 |
|
| 158 |
1 |
| hv_undef(pb -> callbacks); |
| 159 |
2 |
| git_packbuilder_free(pb -> packbuilder); |
| 160 |
2 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |
| 161 |
2 |
| Safefree(pb); |
| 162 |
|
| |