git/list[1] front-page[2] threads[3] people[4] search[5] about
 

graphing commit trees

From
LBLennert Buytenhek <buytenh@wantstofly.org>
Date
May 1, 2005, 20:01 UTC
Message-ID
<20050501200107.GA32703@xi.wantstofly.org>
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);
Message 1 of 1 in “graphing commit trees”
  1. Lennert BuytenhekMay 1, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.