Skip to content

Commit 5e2a29a

Browse files
committed
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.
1 parent 48c6436 commit 5e2a29a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/commit_list.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313

1414
int git_commit_list_time_cmp(const void *a, const void *b)
1515
{
16-
const git_commit_list_node *commit_a = a;
17-
const git_commit_list_node *commit_b = b;
16+
int64_t time_a = ((git_commit_list_node *) a)->time;
17+
int64_t time_b = ((git_commit_list_node *) b)->time;
1818

19-
return (commit_a->time < commit_b->time);
19+
if (time_a < time_b)
20+
return 1;
21+
if (time_a > time_b)
22+
return -1;
23+
24+
return 0;
2025
}
2126

2227
git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p)

0 commit comments

Comments
 (0)