git-messenger.vim icon indicating copy to clipboard operation
git-messenger.vim copied to clipboard

Show total number of revisions

Open petobens opened this issue 6 years ago • 4 comments

I think it would be useful to show the total number of revisions in the History: #0 text: image

Something like History: #0 (0/2). What do you think? Thanks!

petobens avatar Jul 13 '19 15:07 petobens

Thank you for the suggestion.

Yeah, it would be nice to have. However, with current implementation, it requires large code changes and tradeoff.

The history of revisions is a chain of git blame. Based on first source location, git-messenger.vim gets previous revision and source location using git blame. And based on the source location, git-messenger.vim gets older revision and source location using git blame. So it's something like iterating uni-direction linked list.

So git-messenger.vim cannot know the number of revisions under the cursor until it reaches 'no previous revision'. It's possible to fetch all revisions at first :GitMessenger, but it spawns many shell commands and would take time. For those who don't want revisions history, it is a pure overhead.

rhysd avatar Jul 18 '19 10:07 rhysd

Ohh I see. If it's too complicated then feel free to close.

petobens avatar Jul 18 '19 12:07 petobens

@rhysd you don't need to iteratively call git blame, you can get a count directly with e.g. git rev-list --count HEAD <path>. This should match the chain you get from following the blames, though you might also need --no-merges to skip merge commits.

There's still a small performance concern, but it should be fine if this could be called asynchronously, so it doesn't delay the popup. You could also limit the runtime with e.g. --max-count 1001 and display that as 1000+.

toupeira avatar Feb 28 '20 22:02 toupeira

@toupeira

Nice. (I'm sorry for the delay. I missed to catch the comment) I'll consider to add this functionality.

rhysd avatar Jul 27 '20 13:07 rhysd