IntelliJ "Annotate" action sometimes fails with truncated output
Background
While working on a Git project I noticed that when trying to annotate a file (GUI equivalent of git blame), one of three things can happen, depending on file being annotated:
- File gets annotated without any problems,
- An error is shown with message "Number of lines annotated by Git is not equal to number of lines in the file. Check file encoding and line separators"; when clicking to display it anyway it is truncated at around half the length of said file,
- IDE errors out with message along the lines of "Error: Unexpected text end at 24566".
Java unit test files seem to cause the most trouble, probably due to their file/line length, and number of contributors/revisions.
Probably similar to #28...?
System info
wslgit version 0.6.0 official .exe, not additionally configured in any way
WSL: Ubuntu 18.04, Windows 10 Pro build 1803, 17134.228
Default shell changed to zsh
I haven't tried any debugging (to see which command is actually issued to wslgit), or setting WSLGIT_USE_INTERACTIVE_SHELL=false yet (don't know if it will even make sense in this case). I'll try later to reproduce it on my second PC, since it has the same WSL config.
Thanks for your report.
First, it's nice to see that wslgit seems to generally work with IntelliJ, because there is an older issue (#9) which suggests that it does not work with related tools like PHPStorm and Android Studio. Did it require any special configuration in addition to configuring the git executable?
Regarding your issue, I can only guess. Do the files showing the wrong behavior maybe have mixed line endings (i.e. \n and \r\n). This could explain the mismatch. There is also a help page for dealing with different line endings and Git in IntelliJ.
The best way to debug this is probably to find out the exact command that is executed by IntelliJ and then run this command manually in a terminal. Then you can compare the output of Git to the lines shown in IntelliJ.
Did it require any special configuration in addition to configuring the git executable?
No additional configuration was required.
Do the files showing the wrong behavior maybe have mixed line endings
No, LF all the way throughout all projects that I'm currently working on.
Sure, for some functions it sometimes fails (noticed today additional "Failed to generate diff" error), but what is important (commits, merges, branching, push/pull, setting identity for commit) works without any problem whatsoever.
I might have some free time to investigate further in the next week or two, but since it's not a complete dealbreaker for me I won't be giving it the highest priority.
Yes, it appears some pipe/buffer issue. I get this error:
Error:Unexpected text end at 32768
A much simpler .bat file was showing the same issue, and I was hoping this tool could overcome the issue ;)
Update, since I'm a moron and forgot to write earlier. I learned some Rust and did a ~~quick~~ debug session a week ago. Couple of facts from then:
- IntelliJ launches a few robust commands when trying to annotate file, mostly gathering user details
- Commands emmited declare custom output format, with specific byte sequences used as data separators
- Some commands expect input from stdin (which I did not capture for testing, because who would expect that)
So it is most likely a pipe/buffer or/and encoding/conversion issue, as @mbeccati said.
Good news is also that it can easily be replicated on main wslgit repo - annotating src/main.rs file shows one of the errors. Tried both on my work laptop and home desktop, with success every single time.
For me, one TODO remains: capture what IntelliJ sends via stdin, and compare command outputs both on Windows, WSL, and normal Linux environment (if necessary).
@mbeccati So this issue is also present if you call git inside WSL directly from a .bat file? That suggests that the problem is likely elsewhere, not in wslgit. But it would still be interesting to know what is going on.
@tMaxx That sounds good, thanks for investigating. Yes, it would be great to have the exact commands (with inputs) to replicate the issue outside of IntelliJ and compare it with other environments.
Maybe the specific byte sequences you mentioned are messed up somewhere in the conversion/translation between WSL and Windows.
@andy-5 yes, precisely. If I redirect the git output to a file it doesn't seem to be truncated though. This thing remains a mystery to me... I've had to install git for windows to work around the issue.
It seems to be working fine seemingly for all cases that weren't working before - annotating wslgit.rs doesn't trigger an error anymore. And I can't remember when I last saw an error like that on my work laptop.
Windows 10 Pro 17134.407 IntelliJ IDEA 2018.3.1
Haven't updated wslgit since first installing it, so it may not have been its fault to begin with.
@tMaxx I thought we got rid of it, but I got the issue again just a few minutes ago. Suddenly I saw 3/4th of the open file with the green vertical left bar as if I had just added all those lines. Annotating brought up the error again...
Restarting the IDE worked for me. Rubymine 2018.3.5
In my case on Android Studio 4.0 versions gitlab vs local differs, when trying to annotate similar issue