diff options
author | Russell Belfer <rb@github.com> | 2012-11-21 15:39:03 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2012-11-27 13:18:29 -0800 |
commit | a8122b5d4a179456b1a1d9af8d09313e22bfab8d (patch) | |
tree | 0c761b335489f93a6db1aecdde506a037c64dd92 /src/reflog.c | |
parent | 4604a65460b42ee4b3fead03dbb92197d583cc65 (diff) | |
download | libgit2-a8122b5d4a179456b1a1d9af8d09313e22bfab8d.tar.gz |
Fix warnings on Win64 build
Diffstat (limited to 'src/reflog.c')
-rw-r--r-- | src/reflog.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/reflog.c b/src/reflog.c index 72a34f695..ac481fb81 100644 --- a/src/reflog.c +++ b/src/reflog.c @@ -275,7 +275,7 @@ int git_reflog_write(git_reflog *reflog) if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0) goto cleanup; } - + error = git_filebuf_commit(&fbuf, GIT_REFLOG_FILE_MODE); goto success; @@ -411,18 +411,20 @@ size_t git_reflog_entrycount(git_reflog *reflog) return reflog->entries.length; } -const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx) +GIT_INLINE(size_t) reflog_inverse_index(size_t idx, size_t total) { - int pos; + return (total - 1) - idx; +} +const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx) +{ assert(reflog); - pos = git_reflog_entrycount(reflog) - (idx + 1); - - if (pos < 0) + if (idx >= reflog->entries.length) return NULL; - return git_vector_get(&reflog->entries, pos); + return git_vector_get( + &reflog->entries, reflog_inverse_index(idx, reflog->entries.length)); } const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry) @@ -454,7 +456,7 @@ int git_reflog_drop( size_t idx, int rewrite_previous_entry) { - unsigned int entrycount; + size_t entrycount; git_reflog_entry *entry, *previous; assert(reflog); @@ -468,7 +470,8 @@ int git_reflog_drop( reflog_entry_free(entry); - if (git_vector_remove(&reflog->entries, entrycount - (idx + 1)) < 0) + if (git_vector_remove( + &reflog->entries, reflog_inverse_index(idx, entrycount)) < 0) return -1; if (!rewrite_previous_entry) @@ -489,7 +492,7 @@ int git_reflog_drop( /* ...clear the oid_old member of the "new" oldest entry */ if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0) return -1; - + return 0; } |