--- /dev/null
+#!/usr/bin/perl
+use DBI;
+use IPC::Open2;
+
+$password = qx(perl -F= -lane 'print \$F[1] if (\$F[0] eq "password")' \\
+ /mit/sipb-www/.my.cnf);
+chomp $password;
+$dbh = DBI->connect('DBI:mysql:sipb-www+doc;host=sql.mit.edu',
+ 'sipb-www', $password) or die;
+$rows = $dbh->selectall_arrayref('SELECT * FROM wiki', {Slice=>{}});
+foreach $row (@$rows) {
+ next if $row->{author} eq 'trac';
+ print "Processing revision $row->{version} of $row->{name} by $row->{author}...";
+
+ $pid = open2(OUT, IN, qw(git hash-object -w --stdin));
+ print IN $row->{text};
+ close(IN);
+ chomp($blob = <OUT>);
+ waitpid $pid, 0;
+
+ $pid = open2(OUT, IN, qw(git mktree));
+ print IN `git ls-tree $head | grep -v $row->{name}` if $head;
+ print IN "100644 blob $blob\t$row->{name}\n";
+ close(IN);
+ chomp($tree = <OUT>);
+ waitpid $pid, 0;
+
+ $ENV{GIT_AUTHOR_NAME} = "$row->{author} via Trac";
+ $ENV{GIT_AUTHOR_EMAIL} = "$row->{author}\@mit.edu";
+ $ENV{GIT_AUTHOR_DATE} = $row->{time};
+ $pid = open2(OUT, IN, qw{git commit-tree}, $tree, $head ? ('-p', $head) : ());
+ print IN $row->{comment};
+ close(IN);
+ chomp($head = <OUT>);
+ waitpid $pid, 0;
+
+ print "committed as $head.\n";
+}