Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-10-09 20:29:26 +0400
committernulltoken <emeric.fermas@gmail.com>2012-10-26 23:02:01 +0400
commit1f87fa35951d6369bfab722a656ed43365b3579f (patch)
treeb59e8e6d7fad2267c2800be225fbd6ff8668a87a /src/reflog.c
parent27e3c58392a53a66a4b914d570a0af87a3a58c68 (diff)
reflog: fix bogus removal of reflog entries
Diffstat (limited to 'src/reflog.c')
-rw-r--r--src/reflog.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reflog.c b/src/reflog.c
index 17cd6d93f..f0a6e2a8c 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -469,18 +469,18 @@ int git_reflog_drop(
if (!rewrite_previous_entry)
return 0;
- /* No need to rewrite anything when removing the first entry */
- if (idx == 0)
+ /* No need to rewrite anything when removing the most recent entry */
+ if (idx == entrycount - 1)
return 0;
/* There are no more entries in the log */
if (entrycount == 1)
return 0;
- entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx - 1);
+ entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx);
- /* If the last entry has just been removed... */
- if (idx == entrycount - 1) {
+ /* If the oldest entry has just been removed... */
+ if (idx == 0) {
/* ...clear the oid_old member of the "new" last entry */
if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0)
return -1;
@@ -488,7 +488,7 @@ int git_reflog_drop(
return 0;
}
- previous = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx);
+ previous = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx - 1);
git_oid_cpy(&entry->oid_old, &previous->oid_cur);
return 0;