diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Compare author totals by sign
The comparator returned a long difference truncated to int, which could flip sign and leave the ordering inconsistent.
Diffstat (limited to 'source')
-rw-r--r--source/ui-stats.c8
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