From f276ca37cd9fa86d7016f9173a8fcf25f62505bf Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 5 Aug 2026 22:13:30 -1000 Subject: Compare author totals by sign The comparator returned a long difference truncated to int, which could flip sign and leave the ordering inconsistent. --- source/ui-stats.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/ui-stats.c') diff --git a/source/ui-stats.c b/source/ui-stats.c index 4c83cf3..d0fcfd8 100644 --- a/source/ui-stats.c +++ b/source/ui-stats.c @@ -213,7 +213,13 @@ static int cmp_total_commits(const void *a1, const void *a2) const struct authorstat *auth1 = i1->util; const struct authorstat *auth2 = i2->util; - return auth2->total - auth1->total; + // Return the sign only, since a long difference truncated to int could + // flip and leave the comparator inconsistent. + if (auth2->total > auth1->total) + return 1; + if (auth2->total < auth1->total) + return -1; + return 0; } /* Walk the commit DAG once for the configured window. One walk, no -- cgit 2.12.1