| 1 |
|
| MODULE = Git::Raw PACKAGE = Git::Raw::Reflog |
| 2 |
|
| |
| 3 |
|
| SV * |
| 4 |
|
| open(class, reference) |
| 5 |
|
| SV *class |
| 6 |
|
| SV *reference |
| 7 |
|
| |
| 8 |
|
| PREINIT: |
| 9 |
|
| int rc; |
| 10 |
|
| |
| 11 |
|
| Reference ref; |
| 12 |
|
| Reflog reflog; |
| 13 |
|
| |
| 14 |
|
| CODE: |
| 15 |
5 |
| ref = GIT_SV_TO_PTR(Reference, reference); |
| 16 |
|
| |
| 17 |
5 |
| rc = git_reflog_read( |
| 18 |
|
| &reflog, |
| 19 |
|
| git_reference_owner(ref), |
| 20 |
|
| git_reference_name(ref) |
| 21 |
|
| ); |
| 22 |
5 |
| git_check_error(rc); |
| 23 |
|
| |
| 24 |
10 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 25 |
|
| RETVAL, SvPVbyte_nolen(class), reflog, reference |
| 26 |
|
| ); |
| 27 |
|
| |
| 28 |
|
| OUTPUT: RETVAL |
| 29 |
|
| |
| 30 |
|
| void |
| 31 |
|
| delete(self) |
| 32 |
|
| SV *self |
| 33 |
|
| |
| 34 |
|
| PREINIT: |
| 35 |
|
| int rc; |
| 36 |
|
| |
| 37 |
|
| Reference ref; |
| 38 |
|
| |
| 39 |
|
| CODE: |
| 40 |
1 |
| ref = GIT_SV_TO_PTR(Reference, GIT_SV_TO_MAGIC(self)); |
| 41 |
|
| |
| 42 |
1 |
| rc = git_reflog_delete( |
| 43 |
|
| git_reference_owner(ref), git_reference_name(ref) |
| 44 |
|
| ); |
| 45 |
1 |
| git_check_error(rc); |
| 46 |
|
| |
| 47 |
|
| void |
| 48 |
|
| append(self, message, ...) |
| 49 |
|
| SV *self |
| 50 |
|
| const char *message |
| 51 |
|
| |
| 52 |
|
| PROTOTYPE: $$;$ |
| 53 |
|
| |
| 54 |
|
| PREINIT: |
| 55 |
|
| int rc; |
| 56 |
|
| |
| 57 |
|
| git_oid id; |
| 58 |
|
| Signature sig; |
| 59 |
|
| Reference ref; |
| 60 |
|
| git_repository *ref_owner; |
| 61 |
|
| |
| 62 |
|
| CODE: |
| 63 |
3 |
| ref = GIT_SV_TO_PTR(Reference, GIT_SV_TO_MAGIC(self)); |
| 64 |
3 |
| ref_owner = git_reference_owner(ref); |
| 65 |
|
| |
| 66 |
3 |
| rc = git_reference_name_to_id( |
| 67 |
|
| &id, ref_owner, git_reference_name(ref) |
| 68 |
|
| ); |
| 69 |
3 |
| git_check_error(rc); |
| 70 |
|
| |
| 71 |
3 |
▶ | if (items == 3) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items == 3) { |
2 |
1 |
3 |
|
| 72 |
2 |
| sig = GIT_SV_TO_PTR(Signature, ST(2)); |
| 73 |
|
| } else { |
| 74 |
1 |
| rc = git_signature_default(&sig, ref_owner); |
| 75 |
1 |
| git_check_error(rc); |
| 76 |
|
| } |
| 77 |
|
| |
| 78 |
3 |
| rc = git_reflog_append( |
| 79 |
3 |
| GIT_SV_TO_PTR(Reflog, self), |
| 80 |
|
| &id, sig, message |
| 81 |
|
| ); |
| 82 |
|
| |
| 83 |
3 |
▶ | if (items != 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 3) |
1 |
2 |
3 |
|
| 84 |
1 |
| git_signature_free(sig); |
| 85 |
|
| |
| 86 |
3 |
| git_check_error(rc); |
| 87 |
|
| |
| 88 |
|
| void |
| 89 |
|
| drop(self, index) |
| 90 |
|
| Reflog self |
| 91 |
|
| size_t index |
| 92 |
|
| |
| 93 |
|
| PREINIT: |
| 94 |
|
| int rc; |
| 95 |
|
| |
| 96 |
|
| CODE: |
| 97 |
1 |
| rc = git_reflog_drop(self, index, 1); |
| 98 |
1 |
| git_check_error(rc); |
| 99 |
|
| |
| 100 |
|
| void |
| 101 |
|
| write(self) |
| 102 |
|
| Reflog self |
| 103 |
|
| |
| 104 |
|
| PREINIT: |
| 105 |
|
| int rc; |
| 106 |
|
| |
| 107 |
|
| CODE: |
| 108 |
4 |
| rc = git_reflog_write(self); |
| 109 |
4 |
| git_check_error(rc); |
| 110 |
|
| |
| 111 |
|
| SV * |
| 112 |
|
| entry_count(self) |
| 113 |
|
| Reflog self |
| 114 |
|
| |
| 115 |
|
| PREINIT: |
| 116 |
|
| size_t count; |
| 117 |
|
| |
| 118 |
|
| CODE: |
| 119 |
2 |
| count = git_reflog_entrycount (self); |
| 120 |
2 |
| RETVAL = newSViv ((int) count); |
| 121 |
|
| |
| 122 |
|
| OUTPUT: RETVAL |
| 123 |
|
| |
| 124 |
|
| void |
| 125 |
|
| entries(self, ...) |
| 126 |
|
| SV *self |
| 127 |
|
| |
| 128 |
|
| PROTOTYPE: $;$$ |
| 129 |
|
| PREINIT: |
| 130 |
|
| Reflog reflog; |
| 131 |
18 |
| size_t start = 0, end, entry_count; |
| 132 |
|
| |
| 133 |
|
| PPCODE: |
| 134 |
18 |
| reflog = GIT_SV_TO_PTR(Reflog, self); |
| 135 |
18 |
| entry_count = git_reflog_entrycount (reflog); |
| 136 |
|
| |
| 137 |
18 |
▶ | if (items >= 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items >= 2) { |
10 |
8 |
18 |
|
| 138 |
10 |
| SV *index = ST(1); |
| 139 |
|
| |
| 140 |
10 |
▶ | if (!SvIOK(index) || SvIV(index) < 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvIOK(index) || SvIV(index) < 0) |
10 |
0 |
10 |
| if (!SvIOK(index) || SvIV(index) < 0) |
0 |
10 |
10 |
|
| 141 |
0 |
| croak_usage("Invalid type for 'index'"); |
| 142 |
|
| |
| 143 |
10 |
| start = SvUV(index); |
| 144 |
10 |
▶ | if (start >= entry_count) |
Branch: 1 branch
| Branch | True | False | Total |
| if (start >= entry_count) |
1 |
9 |
10 |
|
| 145 |
1 |
| croak_usage("index %" PRIuZ " out of range", start); |
| 146 |
|
| |
| 147 |
9 |
▶ | if (items >= 3) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items >= 3) { |
9 |
0 |
9 |
|
| 148 |
9 |
| SV *count = ST(2); |
| 149 |
|
| size_t retrieve_count; |
| 150 |
|
| |
| 151 |
9 |
▶ | if (!SvIOK(count) || SvIV(count) < 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvIOK(count) || SvIV(count) < 0) |
9 |
0 |
9 |
| if (!SvIOK(count) || SvIV(count) < 0) |
0 |
9 |
9 |
|
| 152 |
0 |
| croak_usage("Invalid type for 'count'"); |
| 153 |
9 |
▶ | if (SvIV(count) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvIV(count) == 0) |
1 |
8 |
9 |
|
| 154 |
1 |
| croak_usage("Invalid value for 'count'"); |
| 155 |
|
| |
| 156 |
8 |
| retrieve_count = SvUV(count); |
| 157 |
8 |
▶ | if ((start + retrieve_count) > entry_count) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((start + retrieve_count) > entry_count) |
2 |
6 |
8 |
|
| 158 |
2 |
| croak_usage("count %" PRIuZ " out of range", retrieve_count); |
| 159 |
|
| |
| 160 |
6 |
| entry_count = retrieve_count; |
| 161 |
|
| } else |
| 162 |
0 |
| entry_count -= start; |
| 163 |
|
| } |
| 164 |
|
| |
| 165 |
14 |
| end = start + entry_count; |
| 166 |
|
| |
| 167 |
33 |
▶ | for (; start < end; ++start) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (; start < end; ++start) { |
19 |
14 |
33 |
|
| 168 |
19 |
| SV *entry = NULL; |
| 169 |
|
| |
| 170 |
|
| const git_reflog_entry *e = |
| 171 |
19 |
| git_reflog_entry_byindex(reflog, start); |
| 172 |
|
| |
| 173 |
19 |
| GIT_NEW_OBJ_WITH_MAGIC( |
| 174 |
|
| entry, "Git::Raw::Reflog::Entry", |
| 175 |
|
| (Reflog_Entry) e, SvRV(self) |
| 176 |
|
| ); |
| 177 |
|
| |
| 178 |
19 |
▶ | mXPUSHs(entry); |
Branch: 1 branch
| Branch | True | False | Total |
| mXPUSHs(entry); |
0 |
19 |
19 |
|
| 179 |
|
| } |
| 180 |
|
| |
| 181 |
14 |
| XSRETURN(entry_count); |
| 182 |
|
| |
| 183 |
|
| void |
| 184 |
|
| DESTROY(self) |
| 185 |
|
| SV *self |
| 186 |
|
| |
| 187 |
|
| CODE: |
| 188 |
5 |
| git_reflog_free(GIT_SV_TO_PTR(Reflog, self)); |
| 189 |
5 |
| SvREFCNT_dec(GIT_SV_TO_MAGIC(self)); |