Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

git-set-file-times 910B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  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. my %ls;
  9. my $commit_time;
  10. my $prefix = @ARGV && $ARGV[0] =~ s/^--prefix=// ? shift : '';
  11. $/ = "\0";
  12. open FH, 'git ls-files -z|' or die $!;
  13. while (<FH>) {
  14. chomp;
  15. $ls{$_} = $_;
  16. }
  17. close FH;
  18. $/ = "\n";
  19. open FH, "git log -r --name-only --no-color --pretty=raw -z @ARGV |" or die $!;
  20. while (<FH>) {
  21. chomp;
  22. if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) {
  23. $commit_time = $1;
  24. } elsif (s/\0\0commit [a-f0-9]{40}$// or s/\0$//) {
  25. my @files = delete @ls{split(/\0/, $_)};
  26. @files = grep { defined $_ } @files;
  27. next unless @files;
  28. map { s/^/$prefix/ } @files;
  29. utime $commit_time, $commit_time, @files;
  30. }
  31. last unless %ls;
  32. }
  33. close FH;