Skip to content

Conversation

lucasadelino
Copy link
Contributor

@lucasadelino lucasadelino commented Aug 20, 2025

This is implemented pretty much as in Magit: by calling git show --format= --shortstat for each commit. In the Magit source, this is described as "experimental and rather slow", but it seems to work just fine for medium-sized repos. Largeish repos (e.g. rust's) cause some slowdown in Neogit, but I didn't see a significant difference when testing with vs. without this patch.

In order to (mostly) follow Magit's presentation, I had to add an optional argument to a couple of util functions, so that I could pad strings with spaces to the left (rather than to the right). This should be OK, but I'll flag these changes for review just in case.

One thing to note is that the UI assumes the addition and the deletion columns will take up to 5 characters (4 digits and a +/- sign), and the changed files column up to 3 characters. Magit will still try to display the columns if any of them go over those limits, but the alignment breaks. This is also the case for this implementation, although the alignment breaks in a slightly different way (see the screenshot below). At first this bugged me, but I think this is reasonable. Trying to display the data at the possible cost of breaking alignment seems better than the alternatives (clamping numbers; pre-allocating more space than needed; etc), and certainly better than preemptively optimizing around single commits that add/delete 10,000+ lines over 1,000+ files.

shortstat_difference

@lucasadelino lucasadelino requested a review from CKolkey August 25, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants