summaryrefslogtreecommitdiff
path: root/src/commit_list.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2016-09-27 13:11:47 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2016-10-06 11:04:55 +0200
commit5e2a29a78c19b110dace4018f0c077d0fb476a53 (patch)
treecfcc28e64561d64655572e09b90d399d3fc9cbd7 /src/commit_list.c
parent48c64362e43f5a11aeca6a6dd2950107d6c8adce (diff)
downloadlibgit2-5e2a29a78c19b110dace4018f0c077d0fb476a53.tar.gz
commit_list: fix the date comparison function
This returns the integer-cast truth value comparing the dates. What we want instead of a (-1, 0, 1) output depending on how they compare.
Diffstat (limited to 'src/commit_list.c')
-rw-r--r--src/commit_list.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/commit_list.c b/src/commit_list.c
index 28948c88b..a1681ffae 100644
--- a/src/commit_list.c
+++ b/src/commit_list.c
@@ -13,10 +13,15 @@
int git_commit_list_time_cmp(const void *a, const void *b)
{
- const git_commit_list_node *commit_a = a;
- const git_commit_list_node *commit_b = b;
+ int64_t time_a = ((git_commit_list_node *) a)->time;
+ int64_t time_b = ((git_commit_list_node *) b)->time;
- return (commit_a->time < commit_b->time);
+ if (time_a < time_b)
+ return 1;
+ if (time_a > time_b)
+ return -1;
+
+ return 0;
}
git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p)