| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Worktree |
| 2 |
|
| |
| 3 |
|
| SV * |
| 4 |
|
| add(class, repo, name, path) |
| 5 |
|
| SV *class |
| 6 |
|
| SV *repo |
| 7 |
|
| SV *name |
| 8 |
|
| SV *path |
| 9 |
|
| |
| 10 |
|
| PREINIT: |
| 11 |
|
| int rc; |
| 12 |
|
| Repository repo_ptr; |
| 13 |
|
| |
| 14 |
|
| Worktree worktree; |
| 15 |
|
| |
| 16 |
|
| CODE: |
| 17 |
2 |
| repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
| 18 |
|
| |
| 19 |
2 |
| rc = git_worktree_add(&worktree, repo_ptr -> repository, |
| 20 |
|
| git_ensure_pv(name, "name"), git_ensure_pv(path, "path"), |
| 21 |
|
| NULL); |
| 22 |
2 |
| git_check_error(rc); |
| 23 |
|
| |
| 24 |
4 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 25 |
|
| RETVAL, SvPVbyte_nolen(class), worktree, SvRV(repo) |
| 26 |
|
| ); |
| 27 |
|
| |
| 28 |
|
| OUTPUT: RETVAL |
| 29 |
|
| |
| 30 |
|
| SV * |
| 31 |
|
| lookup(class, repo, name) |
| 32 |
|
| SV *class |
| 33 |
|
| SV *repo |
| 34 |
|
| SV *name |
| 35 |
|
| |
| 36 |
|
| PREINIT: |
| 37 |
|
| int rc; |
| 38 |
|
| Repository repo_ptr; |
| 39 |
|
| |
| 40 |
|
| Worktree worktree; |
| 41 |
|
| |
| 42 |
|
| CODE: |
| 43 |
2 |
| repo_ptr = GIT_SV_TO_PTR(Repository, repo); |
| 44 |
|
| |
| 45 |
2 |
| rc = git_worktree_lookup(&worktree, repo_ptr -> repository, |
| 46 |
|
| git_ensure_pv(name, "name")); |
| 47 |
2 |
▶ | if (rc != 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc != 0) |
1 |
1 |
2 |
|
| 48 |
1 |
| XSRETURN_UNDEF; |
| 49 |
|
| |
| 50 |
2 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 51 |
|
| RETVAL, SvPVbyte_nolen(class), worktree, SvRV(repo) |
| 52 |
|
| ); |
| 53 |
|
| |
| 54 |
|
| OUTPUT: RETVAL |
| 55 |
|
| |
| 56 |
|
| SV * |
| 57 |
|
| name(self) |
| 58 |
|
| Worktree self |
| 59 |
|
| |
| 60 |
|
| CODE: |
| 61 |
2 |
| RETVAL = newSVpv (git_worktree_name(self), 0); |
| 62 |
|
| |
| 63 |
|
| OUTPUT: RETVAL |
| 64 |
|
| |
| 65 |
|
| SV * |
| 66 |
|
| path(self) |
| 67 |
|
| Worktree self |
| 68 |
|
| |
| 69 |
|
| CODE: |
| 70 |
2 |
| RETVAL = newSVpv (git_worktree_path(self), 0); |
| 71 |
|
| |
| 72 |
|
| OUTPUT: RETVAL |
| 73 |
|
| |
| 74 |
|
| Repository |
| 75 |
|
| repository(self) |
| 76 |
|
| Worktree self |
| 77 |
|
| |
| 78 |
|
| PREINIT: |
| 79 |
|
| int rc; |
| 80 |
1 |
| git_repository *r = NULL; |
| 81 |
1 |
| Repository repo = NULL; |
| 82 |
|
| |
| 83 |
|
| CODE: |
| 84 |
1 |
| rc = git_repository_open_from_worktree(&r, self); |
| 85 |
1 |
| git_check_error(rc); |
| 86 |
|
| |
| 87 |
1 |
| Newxz(repo, 1, git_raw_repository); |
| 88 |
1 |
| repo -> repository = r; |
| 89 |
1 |
| repo -> owned = 1; |
| 90 |
|
| |
| 91 |
1 |
| RETVAL = repo; |
| 92 |
|
| |
| 93 |
|
| OUTPUT: RETVAL |
| 94 |
|
| |
| 95 |
|
| void |
| 96 |
|
| list(class, repo) |
| 97 |
|
| SV *class |
| 98 |
|
| Repository repo |
| 99 |
|
| |
| 100 |
|
| PREINIT: |
| 101 |
|
| int rc, ctx; |
| 102 |
|
| |
| 103 |
3 |
| int i, num_worktrees = 0; |
| 104 |
3 |
| git_strarray worktrees = {0, 0}; |
| 105 |
|
| |
| 106 |
|
| PPCODE: |
| 107 |
3 |
| ctx = GIMME_V; |
| 108 |
|
| |
| 109 |
3 |
▶ | if (ctx != G_VOID) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx != G_VOID) { |
2 |
1 |
3 |
|
| 110 |
2 |
| rc = git_worktree_list(&worktrees, repo -> repository); |
| 111 |
2 |
| git_check_error(rc); |
| 112 |
|
| |
| 113 |
6 |
▶ | for (i = 0; i < worktrees.count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < worktrees.count; ++i) { |
4 |
2 |
6 |
|
| 114 |
4 |
▶ | if (ctx == G_ARRAY) |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx == G_ARRAY) |
2 |
2 |
4 |
|
| 115 |
2 |
▶ | mXPUSHs(newSVpv(worktrees.strings[i], 0)); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(newSVpv(worktrees.strings[i], 0)); |
0 |
2 |
2 |
|
| 116 |
4 |
| ++num_worktrees; |
| 117 |
|
| } |
| 118 |
|
| |
| 119 |
2 |
| git_strarray_free(&worktrees); |
| 120 |
2 |
▶ | if (ctx == G_ARRAY) |
Branch: 1 branch
| Branch | True | False | Total |
| if (ctx == G_ARRAY) |
1 |
1 |
2 |
|
| 121 |
1 |
| XSRETURN(num_worktrees); |
| 122 |
1 |
▶ | mXPUSHi((int) num_worktrees); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHi((int) num_worktrees); |
0 |
1 |
1 |
|
| 123 |
1 |
| XSRETURN(1); |
| 124 |
|
| } else |
| 125 |
1 |
| XSRETURN_EMPTY; |
| 126 |
|
| |
| 127 |
|
| void |
| 128 |
|
| is_locked(self) |
| 129 |
|
| Worktree self |
| 130 |
|
| |
| 131 |
|
| PREINIT: |
| 132 |
|
| int rc; |
| 133 |
3 |
| git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); |
| 134 |
|
| |
| 135 |
|
| PPCODE: |
| 136 |
3 |
| rc = git_worktree_is_locked(&buf, self); |
| 137 |
3 |
▶ | if (rc < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc < 0) { |
0 |
3 |
3 |
|
| 138 |
0 |
| git_buf_dispose(&buf); |
| 139 |
0 |
| git_check_error(rc); |
| 140 |
|
| } |
| 141 |
|
| |
| 142 |
3 |
▶ | if (rc > 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc > 0) |
1 |
2 |
3 |
|
| 143 |
1 |
▶ | mXPUSHp (buf.ptr, buf.size); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHp (buf.ptr, buf.size); |
0 |
1 |
1 |
|
| 144 |
|
| else |
| 145 |
2 |
▶ | mXPUSHi (0); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHi (0); |
0 |
2 |
2 |
|
| 146 |
|
| |
| 147 |
3 |
| git_buf_dispose(&buf); |
| 148 |
3 |
| XSRETURN(1); |
| 149 |
|
| |
| 150 |
|
| void |
| 151 |
|
| is_prunable(self, opts) |
| 152 |
|
| Worktree self |
| 153 |
|
| HV *opts |
| 154 |
|
| |
| 155 |
|
| PREINIT: |
| 156 |
|
| int rc; |
| 157 |
4 |
| git_worktree_prune_options prune_options = GIT_WORKTREE_PRUNE_OPTIONS_INIT; |
| 158 |
|
| |
| 159 |
|
| PPCODE: |
| 160 |
4 |
| git_hv_to_worktree_prune_opts(opts, &prune_options); |
| 161 |
4 |
| rc = git_worktree_is_prunable(self, &prune_options); |
| 162 |
4 |
| XSRETURN_IV(rc); |
| 163 |
|
| |
| 164 |
|
| void |
| 165 |
|
| lock(self, reason) |
| 166 |
|
| Worktree self |
| 167 |
|
| SV *reason |
| 168 |
|
| |
| 169 |
|
| PREINIT: |
| 170 |
|
| int rc; |
| 171 |
|
| |
| 172 |
|
| PPCODE: |
| 173 |
3 |
| rc = git_worktree_lock(self, git_ensure_pv(reason, "reason")); |
| 174 |
3 |
| git_check_error(rc); |
| 175 |
|
| |
| 176 |
2 |
| XSRETURN_YES; |
| 177 |
|
| |
| 178 |
|
| void |
| 179 |
|
| unlock(self) |
| 180 |
|
| Worktree self |
| 181 |
|
| |
| 182 |
|
| PREINIT: |
| 183 |
|
| int rc; |
| 184 |
|
| |
| 185 |
|
| CODE: |
| 186 |
1 |
| rc = git_worktree_unlock(self); |
| 187 |
1 |
| git_check_error(rc); |
| 188 |
|
| |
| 189 |
|
| void |
| 190 |
|
| validate(self) |
| 191 |
|
| Worktree self |
| 192 |
|
| |
| 193 |
|
| PREINIT: |
| 194 |
|
| int rc; |
| 195 |
|
| |
| 196 |
|
| PPCODE: |
| 197 |
2 |
| rc = git_worktree_validate(self); |
| 198 |
2 |
▶ | if (rc == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == 0) |
1 |
1 |
2 |
|
| 199 |
1 |
| XSRETURN_YES; |
| 200 |
|
| |
| 201 |
1 |
| XSRETURN_NO; |
| 202 |
|
| |
| 203 |
|
| void |
| 204 |
|
| prune(self, opts) |
| 205 |
|
| Worktree self |
| 206 |
|
| HV *opts |
| 207 |
|
| |
| 208 |
|
| PREINIT: |
| 209 |
|
| int rc; |
| 210 |
2 |
| git_worktree_prune_options prune_options = GIT_WORKTREE_PRUNE_OPTIONS_INIT; |
| 211 |
|
| |
| 212 |
|
| CODE: |
| 213 |
2 |
| git_hv_to_worktree_prune_opts(opts, &prune_options); |
| 214 |
2 |
| rc = git_worktree_prune(self, &prune_options); |
| 215 |
2 |
| git_check_error(rc); |
| 216 |
|
| |
| 217 |
|
| void |
| 218 |
|
| DESTROY(self) |
| 219 |
|
| SV *self |
| 220 |
|
| |
| 221 |
|
| CODE: |
| 222 |
3 |
| git_worktree_free(GIT_SV_TO_PTR(Worktree, self)); |
| 223 |
3 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |
| 224 |
|
| |