Created
February 11, 2011 22:00
-
-
Save peff/823129 to your computer and use it in GitHub Desktop.
find the last commit that touched a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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