| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Odb |
| 2 |
|
| |
| 3 |
|
| Odb |
| 4 |
|
| new(class) |
| 5 |
|
| SV *class |
| 6 |
|
| |
| 7 |
|
| PREINIT: |
| 8 |
|
| int rc; |
| 9 |
|
| Odb out; |
| 10 |
|
| git_odb *odb; |
| 11 |
|
| |
| 12 |
|
| CODE: |
| 13 |
1 |
| rc = git_odb_new(&odb); |
| 14 |
1 |
| git_check_error(rc); |
| 15 |
|
| |
| 16 |
1 |
| Newxz(out, 1, git_raw_odb); |
| 17 |
1 |
| out -> odb = odb; |
| 18 |
1 |
| RETVAL = out; |
| 19 |
|
| |
| 20 |
|
| OUTPUT: RETVAL |
| 21 |
|
| |
| 22 |
|
| Odb |
| 23 |
|
| open(class, directory) |
| 24 |
|
| SV *class |
| 25 |
|
| SV *directory |
| 26 |
|
| |
| 27 |
|
| PREINIT: |
| 28 |
|
| int rc; |
| 29 |
|
| Odb out; |
| 30 |
|
| git_odb *odb; |
| 31 |
|
| |
| 32 |
|
| CODE: |
| 33 |
2 |
| rc = git_odb_open(&odb, |
| 34 |
|
| git_ensure_pv(directory, "directory") |
| 35 |
|
| ); |
| 36 |
2 |
| git_check_error(rc); |
| 37 |
|
| |
| 38 |
2 |
| Newxz(out, 1, git_raw_odb); |
| 39 |
2 |
| out -> odb = odb; |
| 40 |
2 |
| RETVAL = out; |
| 41 |
|
| |
| 42 |
|
| OUTPUT: RETVAL |
| 43 |
|
| |
| 44 |
|
| void |
| 45 |
|
| add_backend(self, backend, priority) |
| 46 |
|
| Odb self |
| 47 |
|
| SV *backend |
| 48 |
|
| int priority |
| 49 |
|
| |
| 50 |
|
| PREINIT: |
| 51 |
|
| int rc; |
| 52 |
|
| |
| 53 |
|
| CODE: |
| 54 |
3 |
| rc = git_odb_add_backend(self -> odb, |
| 55 |
3 |
| GIT_SV_TO_PTR(Odb::Backend, backend), |
| 56 |
|
| priority |
| 57 |
|
| ); |
| 58 |
3 |
| git_check_error(rc); |
| 59 |
|
| |
| 60 |
3 |
▶ | if (!self -> backends) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!self -> backends) |
2 |
1 |
3 |
|
| 61 |
2 |
| self -> backends = newAV(); |
| 62 |
|
| |
| 63 |
3 |
| av_push(self -> backends, SvRV(backend)); |
| 64 |
3 |
| SvREFCNT_inc_NN(SvRV(backend)); |
| 65 |
|
| |
| 66 |
|
| void |
| 67 |
|
| add_alternate(self, backend, priority) |
| 68 |
|
| Odb self |
| 69 |
|
| SV *backend |
| 70 |
|
| int priority |
| 71 |
|
| |
| 72 |
|
| PREINIT: |
| 73 |
|
| int rc; |
| 74 |
|
| |
| 75 |
|
| CODE: |
| 76 |
1 |
| rc = git_odb_add_alternate(self -> odb, |
| 77 |
1 |
| GIT_SV_TO_PTR(Odb::Backend, backend), |
| 78 |
|
| priority |
| 79 |
|
| ); |
| 80 |
1 |
| git_check_error(rc); |
| 81 |
|
| |
| 82 |
1 |
▶ | if (!self -> backends) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!self -> backends) |
1 |
0 |
1 |
|
| 83 |
1 |
| self -> backends = newAV(); |
| 84 |
|
| |
| 85 |
1 |
| av_push(self -> backends, SvRV(backend)); |
| 86 |
1 |
| SvREFCNT_inc_NN(SvRV(backend)); |
| 87 |
|
| |
| 88 |
|
| SV * |
| 89 |
|
| backend_count(self) |
| 90 |
|
| Odb self |
| 91 |
|
| |
| 92 |
|
| CODE: |
| 93 |
7 |
| RETVAL = newSVuv(git_odb_num_backends(self -> odb)); |
| 94 |
|
| |
| 95 |
|
| OUTPUT: RETVAL |
| 96 |
|
| |
| 97 |
|
| void |
| 98 |
|
| foreach(self, cb) |
| 99 |
|
| Odb self |
| 100 |
|
| SV *cb |
| 101 |
|
| |
| 102 |
|
| PREINIT: |
| 103 |
|
| int rc; |
| 104 |
|
| |
| 105 |
|
| CODE: |
| 106 |
1 |
| rc = git_odb_foreach(self -> odb, |
| 107 |
|
| git_odb_foreach_cbb, |
| 108 |
1 |
| git_ensure_cv(cb, "callback") |
| 109 |
|
| ); |
| 110 |
1 |
▶ | if (rc != GIT_EUSER) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc != GIT_EUSER) |
1 |
0 |
1 |
|
| 111 |
1 |
| git_check_error(rc); |
| 112 |
|
| |
| 113 |
|
| Odb_Object |
| 114 |
|
| read(self, id) |
| 115 |
|
| Odb self |
| 116 |
|
| SV *id |
| 117 |
|
| |
| 118 |
|
| PREINIT: |
| 119 |
|
| int rc; |
| 120 |
|
| |
| 121 |
|
| git_oid oid; |
| 122 |
|
| |
| 123 |
|
| STRLEN len; |
| 124 |
|
| const char *id_str; |
| 125 |
|
| |
| 126 |
|
| Odb_Object obj; |
| 127 |
|
| |
| 128 |
|
| INIT: |
| 129 |
124 |
| id_str = git_ensure_pv_with_len(id, "id", &len); |
| 130 |
|
| |
| 131 |
|
| CODE: |
| 132 |
124 |
| rc = git_oid_fromstrn(&oid, id_str, len); |
| 133 |
124 |
| git_check_error(rc); |
| 134 |
|
| |
| 135 |
124 |
| rc = git_odb_read_prefix(&obj, self -> odb, &oid, len); |
| 136 |
124 |
▶ | if (rc == GIT_ENOTFOUND) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == GIT_ENOTFOUND) |
1 |
123 |
124 |
|
| 137 |
1 |
| XSRETURN_UNDEF; |
| 138 |
123 |
| git_check_error(rc); |
| 139 |
|
| |
| 140 |
123 |
| RETVAL = obj; |
| 141 |
|
| |
| 142 |
|
| OUTPUT: RETVAL |
| 143 |
|
| |
| 144 |
|
| SV * |
| 145 |
|
| write(self, data, type) |
| 146 |
|
| Odb self |
| 147 |
|
| SV *data |
| 148 |
|
| SV *type |
| 149 |
|
| |
| 150 |
|
| PREINIT: |
| 151 |
|
| int rc; |
| 152 |
|
| git_oid id; |
| 153 |
|
| |
| 154 |
|
| STRLEN len; |
| 155 |
|
| const char *d; |
| 156 |
|
| |
| 157 |
|
| CODE: |
| 158 |
1 |
| d = git_ensure_pv_with_len(data, "data", &len); |
| 159 |
|
| |
| 160 |
1 |
| rc = git_odb_write(&id, self -> odb, d, len, |
| 161 |
1 |
| git_ensure_iv(type, "type") |
| 162 |
|
| ); |
| 163 |
1 |
| git_check_error(rc); |
| 164 |
|
| |
| 165 |
1 |
| RETVAL = git_oid_to_sv(&id); |
| 166 |
|
| |
| 167 |
|
| OUTPUT: RETVAL |
| 168 |
|
| |
| 169 |
|
| void |
| 170 |
|
| refresh(self) |
| 171 |
|
| Odb self |
| 172 |
|
| |
| 173 |
|
| CODE: |
| 174 |
2 |
| git_odb_refresh(self -> odb); |
| 175 |
|
| |
| 176 |
|
| SV * |
| 177 |
|
| hash (self, data, type) |
| 178 |
|
| SV *self |
| 179 |
|
| SV *data |
| 180 |
|
| SV *type |
| 181 |
|
| |
| 182 |
|
| PREINIT: |
| 183 |
|
| int rc; |
| 184 |
|
| git_oid id; |
| 185 |
|
| |
| 186 |
|
| STRLEN len; |
| 187 |
|
| const char *d; |
| 188 |
|
| |
| 189 |
|
| CODE: |
| 190 |
1 |
| d = git_ensure_pv_with_len(data, "data", &len); |
| 191 |
|
| |
| 192 |
1 |
| rc = git_odb_hash(&id, d, len, |
| 193 |
1 |
| git_ensure_iv(type, "type") |
| 194 |
|
| ); |
| 195 |
1 |
| git_check_error(rc); |
| 196 |
|
| |
| 197 |
1 |
| RETVAL = git_oid_to_sv(&id); |
| 198 |
|
| |
| 199 |
|
| OUTPUT: RETVAL |
| 200 |
|
| |
| 201 |
|
| void |
| 202 |
|
| DESTROY(self) |
| 203 |
|
| SV* self |
| 204 |
|
| |
| 205 |
|
| PREINIT: |
| 206 |
|
| Odb odb; |
| 207 |
|
| |
| 208 |
|
| CODE: |
| 209 |
9 |
| odb = GIT_SV_TO_PTR(Odb, self); |
| 210 |
9 |
| git_odb_free(odb -> odb); |
| 211 |
|
| |
| 212 |
9 |
▶ | if (odb -> backends) |
Branch: 1 branch
| Branch | True | False | Total |
| if (odb -> backends) |
3 |
6 |
9 |
|
| 213 |
3 |
| av_undef(odb -> backends); |
| 214 |
|
| |
| 215 |
9 |
| Safefree(odb); |
| 216 |
9 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |