Add shortstat to margin popup #1795
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.