5 # Sets mtime and atime of files to the latest commit time in git.
7 # This is useful after the first clone of the rsync repository BEFORE you
8 # do any building. It is also safe if you have done a "make distclean".
12 my $prefix = @ARGV && $ARGV[0] =~ s/^--prefix=// ? shift : '';
14 my $top_dir = `git rev-parse --show-toplevel`;
15 exit 1 unless $top_dir;
18 chdir $top_dir or die "Failed to chdir to $top_dir\: $!\n";
21 open FH, '-|', qw( git ls-files -z ) or die "Failed to fork: $!";
29 open FH, '-|', qw( git log -r --name-only --no-color --pretty=raw -z ), @ARGV or die "Failed to fork: $!";
32 if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) {
34 } elsif (s/\0\0commit [a-f0-9]{40}$// || s/\0$//) {
35 my @files = delete @ls{split(/\0/, $_)};
36 @files = grep { defined $_ } @files;
38 map { s/^/$prefix/ } @files;
39 utime $commit_time, $commit_time, @files;