Friday, June 27, 2014

MPLAB-X git plugin

I was pleased to learn there is a git plugin for MPLAB-X.  I use git heavily, and having it inside the IDE could be a win.  I downloaded the plugin from https://code.google.com/p/nbgit/downloads/list?q=0.4 and it installed without much grief.  (OK, installing a NetBeans plugin is a little weird, but MPLAB makes it fairly obvious.)

Initially I was quite impressed.  The basic things you need to do are right there at your fingertips. To initialize a git repository, you simply choose Initialize Project from the Team menu:

Once you have initialized a repository, the git menu choices show on the main Team menu rather than the Git submenu.

You commit changes to the repository by selecting Commit:

You will be prompted for a commit message where you note down what this particular change was about:


You can view the history of your project with the Browser:
Notice that if you highlight one of the commits, the center pane shows the commit details.

Any changes you make which have not been committed are highlighted in the source window:


You can also select Diff and see changes across all files, including deleted lines:

There are also a couple of nice little touches.  If a project is in git, there is a tiny blue icon next to the project icon to let you know:



And any files with uncommitted changes have their name shown in blue both in the tab and in the Projects pane and the Files pane:


One place where the plugin falls down, badly IMO, is in support for branches.  git branches are easy and lightweight, and as a result they are used more often than they are in previous systems.

As an example, when opening a project (shown below in gitg) which had multiple branches:

The plugin only shows the current branch.  You cannot select a branch, and you don't even know that other branches exist.

However, if you merge the branch back into master, you at least see the branch name as well as the master branch:

The other shortcoming is that the Diff only shows differences between the locally, uncommitted changes and the HEAD.  There doesn't appear to be a way to see differences between two commits.

There is also little support for remote repositories.  You can clone a remote repository, but you cannot push changes back.  And of course, with no support for branches you can't checkout remote branches.

Still, for most of what you would want to do, other than perhaps remote repositories, everything is there and easy.  The plugin also allows you to  add your own commands, so simply adding a Push command covers probably 90% of what I would normally do.

So I have to break down and go to the command line for branches, but that isn't a very high price, and it only needs to be done when switching or merging branches, which doesn't happen very often.

All in all, a really nice improvement in an already impressive IDE.