From e44889bdecbc4b0cb13511af176db9b651bfb3cb Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 6 Aug 2026 21:12:50 -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(-) 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 v2.8.0