summaryrefslogtreecommitdiff
path: root/support/git-set-file-times
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2007-11-17 10:29:13 -0800
committerWayne Davison <wayned@samba.org>2007-11-17 10:29:13 -0800
commit90c98cdc39f640a14fb31e330d9297887926283a (patch)
treef9ae83885f5140291eaee6f90ab103c2de6076f0 /support/git-set-file-times
parentb258ebf8ac029949aea3703b01c5363183806cb3 (diff)
downloadrsync-90c98cdc39f640a14fb31e330d9297887926283a.tar.gz
Adding a support script that can be used to make the checked-out
file-times of an initial clone nicer.
Diffstat (limited to 'support/git-set-file-times')
-rwxr-xr-xsupport/git-set-file-times34
1 files changed, 34 insertions, 0 deletions
diff --git a/support/git-set-file-times b/support/git-set-file-times
new file mode 100755
index 00000000..9ddef25f
--- /dev/null
+++ b/support/git-set-file-times
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+use strict;
+
+# Sets mtime and atime of files to the latest commit time in git.
+#
+# This is useful after the first clone of the rsync repository BEFORE you
+# do any building. It is also safe if you have done a "make distclean".
+
+my %ls;
+my $commit_time;
+
+$/ = "\0";
+open FH, 'git ls-files -z|' or die $!;
+while (<FH>) {
+ chomp;
+ $ls{$_} = $_;
+}
+close FH;
+
+$/ = "\n";
+open FH, "git log -r --name-only --no-color --pretty=raw -z @ARGV |" or die $!;
+while (<FH>) {
+ chomp;
+ if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) {
+ $commit_time = $1;
+ } elsif (s/\0\0commit [a-f0-9]{40}$// or s/\0$//) {
+ my @files = delete @ls{split(/\0/, $_)};
+ @files = grep { defined $_ } @files;
+ next unless @files;
+ utime $commit_time, $commit_time, @files;
+ }
+ last unless %ls;
+}
+close FH;