aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNao Ueda <nao.uedder@gmail.com>2021-02-05 21:33:04 +0900
committerNao Ueda <nao.uedder@gmail.com>2021-02-06 11:01:12 +0900
commit4e475fcaf3f551893f76aaa73f41964290b4ceac (patch)
tree86c84993d9d0833a3119a2e29705eb0fc4856797
parentcfdc7552882c0c3a55d1af3ac29938f7324a95a2 (diff)
downloadgit-file-changed-time-getter-4e475fcaf3f551893f76aaa73f41964290b4ceac.tar.gz
git-file-changed-time-getter-4e475fcaf3f551893f76aaa73f41964290b4ceac.tar.bz2
git-file-changed-time-getter-4e475fcaf3f551893f76aaa73f41964290b4ceac.zip
Be able to treat files that have never changed.
-rw-r--r--time-getter.pl14
1 files changed, 14 insertions, 0 deletions
diff --git a/time-getter.pl b/time-getter.pl
index 5335fbd..06b890d 100644
--- a/time-getter.pl
+++ b/time-getter.pl
@@ -5,6 +5,7 @@ use strict;
open (F, 'git ls-tree -r HEAD|');
my %list;
+my %all_file;
# 辞書作る
while (<F>) {
@@ -14,6 +15,7 @@ while (<F>) {
my $hash = $info[-2];
$list{$filename} = $hash;
+ $all_file{$filename} = 1;
}
close(F);
@@ -46,11 +48,16 @@ while (<COMMITS>) {
open (BLOBS, "git ls-tree -r $tree |");
+ my %remained = %all_file;
while (<BLOBS>) {
my @tmp = split(/\s+/);
my $filename = $tmp[-1];
my $blobhash = $tmp[-2];
+ if ($remained{$filename}) {
+ delete $remained{$filename};
+ }
+
if (!$list{$filename}) {
next;
}
@@ -58,9 +65,16 @@ while (<COMMITS>) {
if ($list{$filename} !~ /$blobhash/) {
print $filename . ": " . $prevtimestamp . " \n";
delete ($list{$filename});
+ delete ($all_file{$filename});
}
}
+ foreach my $filename (keys(%remained)) {
+ print $filename . ": " . $prevtimestamp . " \n";
+ delete ($list{$filename});
+ delete ($all_file{$filename});
+ }
+
$prevtimestamp = $timestamp;
close (BLOBS);