| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Branch |
| 2 |
|
| |
| 3 |
|
| BOOT: |
| 4 |
|
| { |
| 5 |
87 |
| AV *isa = get_av("Git::Raw::Branch::ISA", 1); |
| 6 |
87 |
| av_push(isa, newSVpv("Git::Raw::Reference", 0)); |
| 7 |
|
| } |
| 8 |
|
| |
| 9 |
|
| SV * |
| 10 |
|
| create(class, repo, name, target) |
| 11 |
|
| SV *class |
| 12 |
|
| SV *repo |
| 13 |
|
| SV *name |
| 14 |
|
| SV *target |
| 15 |
|
| |
| 16 |
|
| PREINIT: |
| 17 |
|
| int rc; |
| 18 |
|
| |
| 19 |
|
| Commit obj; |
| 20 |
|
| Reference ref; |
| 21 |
|
| Repository repo_ptr; |
| 22 |
|
| |
| 23 |
|
| INIT: |
| 24 |
14 |
| obj = (Commit) git_sv_to_obj(target); |
| 25 |
|
| |
| 26 |
|
| CODE: |
| 27 |
14 |
| repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
| 28 |
|
| |
| 29 |
14 |
| rc = git_branch_create( |
| 30 |
|
| &ref, repo_ptr -> repository, |
| 31 |
14 |
| SvPVbyte_nolen(name), obj, 0 |
| 32 |
|
| ); |
| 33 |
|
| |
| 34 |
14 |
| git_check_error(rc); |
| 35 |
|
| |
| 36 |
28 |
▶ | GIT_NEW_OBJ_WITH_MAGIC( |
Branch: 1 branch
| Branch | True | False | Total |
| GIT_NEW_OBJ_WITH_MAGIC( |
14 |
0 |
14 |
|
| 37 |
|
| RETVAL, SvPVbyte_nolen(class), ref, SvRV(repo) |
| 38 |
|
| ); |
| 39 |
|
| |
| 40 |
|
| OUTPUT: RETVAL |
| 41 |
|
| |
| 42 |
|
| SV * |
| 43 |
|
| lookup(class, repo, name, is_local) |
| 44 |
|
| SV *class |
| 45 |
|
| SV *repo |
| 46 |
|
| SV *name |
| 47 |
|
| bool is_local |
| 48 |
|
| |
| 49 |
|
| PREINIT: |
| 50 |
|
| int rc; |
| 51 |
|
| Reference branch; |
| 52 |
|
| Repository repo_ptr; |
| 53 |
|
| |
| 54 |
15 |
| git_branch_t type = is_local ? |
| 55 |
15 |
▶ | GIT_BRANCH_LOCAL : |
Branch: 1 branch
| Branch | True | False | Total |
| GIT_BRANCH_LOCAL : |
14 |
1 |
15 |
|
| 56 |
|
| GIT_BRANCH_REMOTE ; |
| 57 |
|
| |
| 58 |
|
| CODE: |
| 59 |
15 |
| repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
| 60 |
15 |
| rc = git_branch_lookup( |
| 61 |
|
| &branch, repo_ptr -> repository, |
| 62 |
15 |
| SvPVbyte_nolen(name), type |
| 63 |
|
| ); |
| 64 |
|
| |
| 65 |
15 |
▶ | if (rc == GIT_ENOTFOUND) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == GIT_ENOTFOUND) { |
2 |
13 |
15 |
|
| 66 |
2 |
| RETVAL = &PL_sv_undef; |
| 67 |
|
| } else { |
| 68 |
13 |
| git_check_error(rc); |
| 69 |
|
| |
| 70 |
26 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 71 |
|
| RETVAL, SvPVbyte_nolen(class), branch, SvRV(repo) |
| 72 |
|
| ); |
| 73 |
|
| } |
| 74 |
|
| |
| 75 |
|
| OUTPUT: RETVAL |
| 76 |
|
| |
| 77 |
|
| void |
| 78 |
|
| move(self, name, force) |
| 79 |
|
| SV *self |
| 80 |
|
| SV *name |
| 81 |
|
| bool force |
| 82 |
|
| |
| 83 |
|
| PREINIT: |
| 84 |
|
| int rc; |
| 85 |
|
| |
| 86 |
|
| Branch new_branch; |
| 87 |
|
| Branch old_branch; |
| 88 |
|
| |
| 89 |
|
| INIT: |
| 90 |
1 |
| old_branch = GIT_SV_TO_PTR(Branch, self); |
| 91 |
|
| |
| 92 |
|
| CODE: |
| 93 |
1 |
| rc = git_branch_move( |
| 94 |
1 |
| &new_branch, old_branch, SvPVbyte_nolen(name), force |
| 95 |
|
| ); |
| 96 |
|
| |
| 97 |
1 |
| git_check_error(rc); |
| 98 |
|
| |
| 99 |
|
| SV * |
| 100 |
|
| upstream(self, ...) |
| 101 |
|
| SV *self |
| 102 |
|
| |
| 103 |
|
| PREINIT: |
| 104 |
|
| int rc; |
| 105 |
|
| |
| 106 |
|
| Branch branch; |
| 107 |
|
| Reference ref; |
| 108 |
|
| |
| 109 |
|
| CODE: |
| 110 |
2 |
| branch = GIT_SV_TO_PTR(Branch, self); |
| 111 |
|
| |
| 112 |
2 |
| RETVAL = &PL_sv_undef; |
| 113 |
|
| |
| 114 |
2 |
▶ | if (items == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items == 2) { |
0 |
2 |
2 |
|
| 115 |
0 |
| const char *name = NULL; |
| 116 |
|
| |
| 117 |
0 |
▶ | if (SvOK(ST(1))) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(ST(1))) { |
0 |
0 |
0 |
|
| 118 |
0 |
▶ | if (sv_isobject(ST(1))) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_isobject(ST(1))) { |
0 |
0 |
0 |
|
| 119 |
0 |
▶ | if (sv_derived_from(ST(1), "Git::Raw::Reference")) |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(ST(1), "Git::Raw::Reference")) |
0 |
0 |
0 |
|
| 120 |
0 |
| name = git_reference_shorthand(GIT_SV_TO_PTR(Reference, ST(1))); |
| 121 |
|
| else |
| 122 |
0 |
| croak_usage("Invalid type for 'upstream'. Expected a 'Git::Raw::Reference' or " |
| 123 |
|
| "'Git::Raw::Branch'"); |
| 124 |
|
| } else |
| 125 |
0 |
| name = git_ensure_pv(ST(1), "upstream"); |
| 126 |
|
| } |
| 127 |
|
| |
| 128 |
0 |
| rc = git_branch_set_upstream(branch, name); |
| 129 |
0 |
| git_check_error(rc); |
| 130 |
|
| } |
| 131 |
|
| |
| 132 |
2 |
| rc = git_branch_upstream(&ref, branch); |
| 133 |
|
| |
| 134 |
2 |
▶ | if (rc != GIT_ENOTFOUND) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc != GIT_ENOTFOUND) { |
0 |
2 |
2 |
|
| 135 |
0 |
| git_check_error(rc); |
| 136 |
|
| |
| 137 |
0 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 138 |
|
| RETVAL, "Git::Raw::Reference", ref, GIT_SV_TO_MAGIC(self) |
| 139 |
|
| ); |
| 140 |
|
| } |
| 141 |
|
| |
| 142 |
|
| OUTPUT: RETVAL |
| 143 |
|
| |
| 144 |
|
| SV * |
| 145 |
|
| upstream_name(self) |
| 146 |
|
| SV *self |
| 147 |
|
| |
| 148 |
|
| PREINIT: |
| 149 |
|
| int rc; |
| 150 |
|
| |
| 151 |
|
| Reference ref; |
| 152 |
1 |
| git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); |
| 153 |
|
| |
| 154 |
|
| CODE: |
| 155 |
1 |
| RETVAL = &PL_sv_undef; |
| 156 |
|
| |
| 157 |
1 |
| ref = GIT_SV_TO_PTR(Reference, self); |
| 158 |
|
| |
| 159 |
1 |
| rc = git_branch_upstream_name( |
| 160 |
|
| &buf, |
| 161 |
|
| git_reference_owner(ref), |
| 162 |
|
| git_reference_name(ref) |
| 163 |
|
| ); |
| 164 |
|
| |
| 165 |
1 |
▶ | if (rc == GIT_OK) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == GIT_OK) |
0 |
1 |
1 |
|
| 166 |
0 |
| RETVAL = newSVpv(buf.ptr, buf.size); |
| 167 |
|
| |
| 168 |
1 |
| git_buf_dispose(&buf); |
| 169 |
|
| |
| 170 |
1 |
▶ | if (rc != GIT_ENOTFOUND) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc != GIT_ENOTFOUND) |
0 |
1 |
1 |
|
| 171 |
0 |
| git_check_error(rc); |
| 172 |
|
| |
| 173 |
|
| OUTPUT: RETVAL |
| 174 |
|
| |
| 175 |
|
| SV * |
| 176 |
|
| remote_name(self) |
| 177 |
|
| SV *self |
| 178 |
|
| |
| 179 |
|
| PREINIT: |
| 180 |
|
| int rc; |
| 181 |
|
| |
| 182 |
|
| Reference ref; |
| 183 |
1 |
| git_buf upstream = GIT_BUF_INIT_CONST(NULL, 0); |
| 184 |
1 |
| git_buf remote = GIT_BUF_INIT_CONST(NULL, 0); |
| 185 |
|
| |
| 186 |
|
| CODE: |
| 187 |
1 |
| RETVAL = &PL_sv_undef; |
| 188 |
|
| |
| 189 |
1 |
| ref = GIT_SV_TO_PTR(Reference, self); |
| 190 |
|
| |
| 191 |
1 |
| rc = git_branch_upstream_name( |
| 192 |
|
| &upstream, |
| 193 |
|
| git_reference_owner(ref), |
| 194 |
|
| git_reference_name(ref) |
| 195 |
|
| ); |
| 196 |
|
| |
| 197 |
1 |
▶ | if (rc == GIT_OK) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == GIT_OK) { |
0 |
1 |
1 |
|
| 198 |
0 |
| rc = git_branch_remote_name( |
| 199 |
|
| &remote, |
| 200 |
|
| git_reference_owner(ref), |
| 201 |
0 |
| upstream.ptr); |
| 202 |
|
| |
| 203 |
0 |
▶ | if (rc == GIT_OK) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == GIT_OK) |
0 |
0 |
0 |
|
| 204 |
0 |
| RETVAL = newSVpv(remote.ptr, remote.size); |
| 205 |
|
| } |
| 206 |
|
| |
| 207 |
1 |
| git_buf_dispose(&upstream); |
| 208 |
1 |
| git_buf_dispose(&remote); |
| 209 |
|
| |
| 210 |
1 |
▶ | if (rc != GIT_ENOTFOUND) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc != GIT_ENOTFOUND) |
0 |
1 |
1 |
|
| 211 |
0 |
| git_check_error(rc); |
| 212 |
|
| |
| 213 |
|
| OUTPUT: RETVAL |
| 214 |
|
| |
| 215 |
|
| SV * |
| 216 |
|
| is_head(self) |
| 217 |
|
| Branch self |
| 218 |
|
| |
| 219 |
|
| CODE: |
| 220 |
1 |
| RETVAL = newSViv(git_branch_is_head(self)); |
| 221 |
|
| |
| 222 |
|
| OUTPUT: RETVAL |
| 223 |
|
| |
| 224 |
|
| void |
| 225 |
|
| DESTROY(self) |
| 226 |
|
| SV *self |
| 227 |
|
| |
| 228 |
|
| CODE: |
| 229 |
31 |
| git_reference_free(GIT_SV_TO_PTR(Reference, self)); |
| 230 |
31 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |