Changed d_name() to be a static inline function.
[rsync.git] / support / git-set-file-times
blob85d854e883988a699ddfef2c833bec00b1dce470
1 #!/usr/bin/perl -w
2 use strict;
4 # Sets mtime and atime of files to the latest commit time in git.
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".
9 my %ls;
10 my $commit_time;
11 my $prefix = @ARGV && $ARGV[0] =~ s/^--prefix=// ? shift : '';
13 $/ = "\0";
14 open FH, 'git ls-files -z|' or die $!;
15 while (<FH>) {
16 chomp;
17 $ls{$_} = $_;
19 close FH;
21 $/ = "\n";
22 open FH, "git log -r --name-only --no-color --pretty=raw -z @ARGV |" or die $!;
23 while (<FH>) {
24 chomp;
25 if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) {
26 $commit_time = $1;
27 } elsif (s/\0\0commit [a-f0-9]{40}$// or s/\0$//) {
28 my @files = delete @ls{split(/\0/, $_)};
29 @files = grep { defined $_ } @files;
30 next unless @files;
31 map { s/^/$prefix/ } @files;
32 utime $commit_time, $commit_time, @files;
34 last unless %ls;
36 close FH;