Today we will talk about a feature in Eclipse that lets you check Git revision history of a particular line. It can be very useful especially if you are working on large file with hundreds or thousands of lines of code. If you are one of the developers who work with legacy codebase, you are probably familiar to the situation. One bug is reported. From the error logs you can see that it is throwing an exception from a particular line. But you don’t have much clue about what the line actually does or why the change was made in the first place. You don’t have proper documentation & you don’t know the old Jira ticket which was used to make the change. Simply put, you don’t have context & you don’t know who made the change. And you are afraid that if you try to fix it, you might introduce new bug. One tedious way to solve this would be to keep checking the Git revision history of the file. But if the file is old (may be written several years back) & contains thousands of lines, then most likely there would be hundreds of code commits. It is not practically feasible to scroll through all the code changes & find the actual Git revision for a particular line. In this scenario, this feature can come really handy. Instead of reviewing code commit history of the whole file, you will only review the commit history for that particular line. And with some luck you might get a Jira ticket which actually has some context. But that requires the good practice of adding Jira ticket id while committing the code. At the very least you can find out who did the change. Hopefully the person is still working in the company :).
Here is how you can do this check using Eclipse IDE. You need to right click on the source file & select Team -> Show Revision Information.
You will get coloured line numbers as shown in the screenshot below. You click on the line number for which you want to check the Git revision history. You will get a box similar to the screenshot below. You will see Git revision details of last code modification in that line along with the code difference.
If that is not the change you want, you need go further back. Just go to that Git revision state by clicking show revision information hyperlink from the above box. It will open the file in that Git revision state. You can then again use Team -> Show Revision Information to check earlier code change from that particular Git revision. This should make debugging a lot easier.