#!/usr/bin/perl use File::Find; use File::Find::Closures qw(find_regular_files); use Git::Repository; use Time::Stamp qw(gmstamp); my ($want, $files) = find_regular_files(); my $author = shift; $author = 'Unknown' unless defined $author; my $email = shift; $email = '<>' unless defined $email; my $dir = shift; $dir = '.' unless $dir; File::Find::find($want, $dir); my %ts; foreach ($files->()) { next if m|^\.git/|; next if m|^git-slurp$|; my $ts = gmstamp((stat $_)[9]); push @{$ts{$ts}}, $_; } my $git = Git::Repository->new({ env => { GIT_AUTHOR_EMAIL => $email, GIT_AUTHOR_NAME => $author, }, } ); print $git->work_tree, "\n"; foreach my $ts (sort { $a cmp $b } keys %ts) { print "$ts @{$ts{$ts}}\n"; foreach my $file (@{$ts{$ts}}) { $git->run('add', $file); } $git->run('commit', '--date', $ts, '-m', "add files for $ts"); }