git-dot

BooK on 2009-11-12T16:50:11

I'm currently experimenting with creating graphs using Git... I'm not using historical data, or even data at all (I'll soon know the SHA1 of the empty tree by heart), just nodes with %s as their label (I have yet to find a use for the rest of the metadata).

gitk is nice to look at historical information, but not so good for graphs. On the other hand, GraphViz is great for showing graphs.

What's best than Perl (and a tiny wrapping of shell on top) to produce graphs?

    #!/bin/sh
    # create a good looking graph with dot
    echo "digraph G {"
    git log --pretty=format:"%h %p" $* \
    | perl -lna  -e 'print qq("$F[0]";),map{qq("$_"->"$F[0]";)}@F[1..$#F]'
    echo "}"

The output of this is usually boring, so just but pipe it to dot -Tpng -ograph.png and watch the pretty pictures.

Also, imagine a graph that has a full filesystem attached to each node. This is exactly the kind of stuff that Git can give us.

Not that I have any idea what this could be used for...


Cool!

jdavidb on 2009-11-16T20:48:02

Sounds like a fun way to spend time. :) I'm sure there are a lot of possibilities for this, down the road.

Re:Cool!

BooK on 2009-11-17T08:02:46

Actually, I have at least two ideas about this. ;-)

The first one will be the topic of the next entry of my use Perl journal, and the second is the basis of yet another grand application.

Re:Cool!

jdavidb on 2009-11-17T17:06:39

Cool! I look forward to seeing what marvelous applications the git storage engine can be bent toward. :)

Re:Cool!

BooK on 2009-11-17T20:14:24

Oops, I may have set your expectations too high...

Actually:

  • The first idea uses git but really belongs to the Acme namespace.
  • The second idea is based on the principles at work in the git object database, but will most probably not use git directly (if I ever get around to it).