Commit | Line | Data |
---|---|---|
90c98cdc WD |
1 | #!/usr/bin/perl -w |
2 | use strict; | |
3 | ||
4 | # Sets mtime and atime of files to the latest commit time in git. | |
5 | # | |
6 | # This is useful after the first clone of the rsync repository BEFORE you | |
7 | # do any building. It is also safe if you have done a "make distclean". | |
8 | ||
9 | my %ls; | |
10 | my $commit_time; | |
11 | ||
12 | $/ = "\0"; | |
13 | open FH, 'git ls-files -z|' or die $!; | |
14 | while (<FH>) { | |
15 | chomp; | |
16 | $ls{$_} = $_; | |
17 | } | |
18 | close FH; | |
19 | ||
20 | $/ = "\n"; | |
21 | open FH, "git log -r --name-only --no-color --pretty=raw -z @ARGV |" or die $!; | |
22 | while (<FH>) { | |
23 | chomp; | |
24 | if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) { | |
25 | $commit_time = $1; | |
26 | } elsif (s/\0\0commit [a-f0-9]{40}$// or s/\0$//) { | |
27 | my @files = delete @ls{split(/\0/, $_)}; | |
28 | @files = grep { defined $_ } @files; | |
29 | next unless @files; | |
30 | utime $commit_time, $commit_time, @files; | |
31 | } | |
32 | last unless %ls; | |
33 | } | |
34 | close FH; |