|
The one thing that's worse about Git compared to Subversion is that
git-blame is so much harder to use than svn blame. The output from
git-blame is very wide so if you run it on the terminal then often
most of the line of source code will be cropped off the right
edge. SVN's revision numbers are replaced with a git commit hash so
it's also not immediatly obvious what the parent of a commit is from
the information in git-blame. When I use either blame command, I often
find the commit reported against a given line is not the change that
I'm interested in so I usually want to re-run the annotation with the
parent commit.
I thought it might be fun to knock up a program to browse the output
of git-blame. I initially thought 'oh that's easy, that'll take about
half an hour' so I cobbled together a quick program in Ruby with the
GTK bindings. It was pretty quick to write because Ruby (like Perl)
has excellent support for processing text. However I eventually got
fed up with the Ruby GTK bindings because they are randomly missing
bindings for some functions that I wanted and it's difficult to
debug. After discovering
this bug I got fed up and rewrote it in C. I also ended up making
it much more complicated because now it tries to run git
asynchronously and process the output as it comes using the glib
main-loop.
So far you can see the source code for the file you've annotated with
the hash of the commit for the that line. A tooltip is displayed for
the commit with a short summary. If you click on the commit you get
more information in a dialog and you can jump to the parent commit
from there.
The screenshot gives away that I stole a function from ebassi's Tweet and also that I fixed a
tiny bug in it :)
There's quite a lot left to do:
- I would like to add forward and back buttons to the main window so
that you can move through the history of what you have visited.
- Searching the source and jumping to a line number are probably
pretty essential.
- It should probably use GtkSourceView instead of my
crazy custom widget.
- The UI looks nasty
I also should probably have tried to implement within the giggle
source code but I didn't look at this until I'd got too far. It looks
like giggle already has a lot of code to handle running git
asynchrously so I could've avoided a lot of work.
The code is available on Github at http://github.com/bpeel/blame-browse
|