Skip to content

Commit

Permalink
Git commit touch which files
Browse files Browse the repository at this point in the history
Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
  • Loading branch information
unixbhaskar committed Sep 7, 2022
1 parent 5bbe312 commit 1efacee
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions which_git_commit_last_touched_the_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/perl

my %attributions;
my @files;

open IN, "git ls-tree -r --full-name HEAD |" or die;
while (<IN>) {
if (/^\S+\s+blob \S+\s+(\S+)$/) {
push(@files, $1);
$attributions{$1} = -1;
}
}
close IN;

my $remaining = $#files + 1;

open IN, "git log -r --root --raw --no-abbrev --pretty=format:%h~%an~%ad~ |" or die;
while (<IN>) {
if (/^([^:~]+)~(.*)~([^~]+)~$/) {
($commit, $author, $date) = ($1, $2, $3);
} elsif (/^:\S+\s+1\S+\s+\S+\s+\S+\s+\S\s+(.*)$/) {
if ($attributions{$1} == -1) {
$attributions{$1} = "$author, $date ($commit)";
$remaining--;
if ($remaining <= 0) {
break;
}
}
}
}
close IN;

for $f (@files) {
print "$f $attributions{$f}\n";
}

0 comments on commit 1efacee

Please sign in to comment.