Skip to content

Instantly share code, notes, and snippets.

@peff
Created February 11, 2011 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peff/823129 to your computer and use it in GitHub Desktop.
Save peff/823129 to your computer and use it in GitHub Desktop.
find the last commit that touched a file
#!/bin/sh
commit=HEAD
pathspec=
git log --format='%H%n %s' --name-status --no-merges --no-renames $commit -- $pathspec |
perl -e '
while(<>) {
if (/^[0-9a-f]{40}$/) {
$sha1 = $&;
}
elsif (/^ (.*)/) {
$subject = $1;
}
elsif (/^.\t(.*)/) {
$last{$1} = [$sha1, $subject]
unless exists $last{$1};
}
}
foreach my $file (sort keys(%last)) {
print join(" ", $file, @{$last{$file}}), "\n";
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment