Skip to content

Commit 79c2392

Browse files
committed
Added script git-force-mtimes
1 parent 9088d97 commit 79c2392

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

git-force-mtimes

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/perl
2+
# Sets mtimes of all files in the reprository their last change date
3+
# based on git's log. Useful to avoid too new dates after a
4+
# checkout.
5+
6+
my %seen;
7+
my $date;
8+
open(LOG, "git log --pretty=format:'date: %ct' --name-only |") || die "git log failed: $!";
9+
while (<LOG>) {
10+
chomp;
11+
if (/^date: (\d+)$/) {
12+
$date=$1;
13+
}
14+
elsif (! /^$/ && ! $seen{$_}) {
15+
$seen{$_}=1;
16+
# git log can list deleted files, so error is ignored
17+
utime($date, $date, $_);
18+
}
19+
}
20+
close LOG || die "git log failed: $!";

0 commit comments

Comments
 (0)