threads / discuss / 422

graphing commit trees

Subject: graphing commit trees

## tl;dr

One message between May 1, 2005 and May 1, 2005.

replies: 0people: 1as markdown or json

Lennert Buytenhek· May 1, 2005, 20:01 UTC · lore
Hi!

As a 5-minute hack to see how easy it'd be to create trees from commit objects: the attached perl script creates a file suitable for feeding to dot/dotty from the graphviz suite. Example graph at:

	http://www.liacs.nl/~buytenh/graph_42d4dc3f4e1ec1396371aac89d0dccfdd977191b.png
Warning: big image (2746x41363), many apps can't display it properly.
(mozilla gives an error, eog shows only the top 32768 pixel rows, gimp
seems to work.)
--L
#!/usr/bin/perl
my %processed;
sub traverse {
        my $commit = shift;
        my $parent;
        my @parents;
        return if (defined $processed{$commit});
        $processed{$commit} = "";
        @parents = split(" ", `git-cat-file commit $commit | grep "^parent " | awk '{print \$2}'`);
        foreach $parent (@parents) {
                print "\"$parent\" -> \"$commit\"\n";
                traverse($parent);
        }
}
sub mk_graph {
        my $root = shift;
        print "digraph blah_$root {\n";
        traverse($root);
        print "}\n";
}

$root = `cat .git/HEAD`; chomp $root;

mk_graph($root);

← back to recent threads