* @param idx the position to lookup
* @return the entry; NULL if not found
*/
- GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog, unsigned int idx);
+ GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog, size_t idx);
+/**
+ * Remove an entry from the reflog by its index
+ *
+ * To ensure there's no gap in the log history, set the `rewrite_previosu_entry` to 1.
+ * When deleting entry `n`, member old_oid of entry `n-1` (if any) will be updated with
+ * the value of memeber new_oid of entry `n+1`.
+ *
+ * @param reflog a previously loaded reflog.
+ *
+ * @param idx the position of the entry to remove.
+ *
+ * @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
+ *
+ * @return 0 on success or an error code.
+ */
+GIT_EXTERN(int) git_reflog_drop(
+ git_reflog *reflog,
+ unsigned int idx,
+ int rewrite_previous_entry);
+
/**
* Get the old oid
*
}
for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
- int match = match_string(date, timezone_names[i].name);
- if (match >= 3 || match == (int)strlen(timezone_names[i].name)) {
+ size_t match = match_string(date, timezone_names[i].name);
- if (match >= 3 || match == (int)strlen(timezone_names[i].name)) {
++ if (match >= 3 || match == strlen(timezone_names[i].name)) {
int off = timezone_names[i].offset;
/* This is bogus, but we like summer */
return ret;
}
- void gitno_buffer_setup_callback(git_transport *t, gitno_buffer *buf, char *data, unsigned int len, int (*recv)(gitno_buffer *buf), void *cb_data)
++void gitno_buffer_setup_callback(
++ git_transport *t,
++ gitno_buffer *buf,
++ char *data,
++ size_t len,
++ int (*recv)(gitno_buffer *buf), void *cb_data)
+{
+ memset(buf, 0x0, sizeof(gitno_buffer));
+ memset(data, 0x0, len);
+ buf->data = data;
+ buf->len = len;
+ buf->offset = 0;
+ buf->fd = t->socket;
+ buf->recv = recv;
+ buf->cb_data = cb_data;
+}
+
- void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, unsigned int len)
++void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, size_t len)
+{
+#ifdef GIT_SSL
+ if (t->use_ssl) {
+ gitno_buffer_setup_callback(t, buf, data, len, gitno__recv_ssl, NULL);
+ buf->ssl = &t->ssl;
+ } else
+#endif
+ gitno_buffer_setup_callback(t, buf, data, len, gitno__recv, NULL);
+}
+
/* Consume up to ptr and move the rest of the buffer to the beginning */
void gitno_consume(gitno_buffer *buf, const char *ptr)
{
#ifdef GIT_SSL
struct gitno_ssl *ssl;
#endif
-} gitno_buffer;
+ int (*recv)(gitno_buffer *buffer);
+ void *cb_data;
+};
- void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, unsigned int len);
- void gitno_buffer_setup_callback(git_transport *t, gitno_buffer *buf, char *data, unsigned int len, int (*recv)(gitno_buffer *buf), void *cb_data);
+ void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, size_t len);
++void gitno_buffer_setup_callback(git_transport *t, gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data);
int gitno_recv(gitno_buffer *buf);
+int gitno__recv(gitno_buffer *buf);
void gitno_consume(gitno_buffer *buf, const char *ptr);
void gitno_consume_n(gitno_buffer *buf, size_t cons);
memcpy(out->id, src->id, sizeof(out->id));
}
- int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, unsigned int len)
-int git_oid_cmp(const git_oid *a, const git_oid *b)
-{
- return memcmp(a->id, b->id, sizeof(a->id));
-}
-
+ int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, size_t len)
{
const unsigned char *a = oid_a->id;
const unsigned char *b = oid_b->id;