X-Git-Url: https://git.octo.it/?p=git.git;a=blobdiff_plain;f=git-annotate.perl;h=a6a7a482cdcf34e3a1d545c7d5deab599a7c0d2f;hp=9df72a1662c47790a7d97309e40dc1051e5f7fcc;hb=74237d6236d7e32f69469ff26df3f3bb3875f523;hpb=be767c91724275c4534965c0d25c452b76057602 diff --git a/git-annotate.perl b/git-annotate.perl index 9df72a16..a6a7a482 100755 --- a/git-annotate.perl +++ b/git-annotate.perl @@ -10,9 +10,10 @@ use warnings; use strict; use Getopt::Long; use POSIX qw(strftime gmtime); +use File::Basename qw(basename dirname); sub usage() { - print STDERR 'Usage: ${\basename $0} [-s] [-S revs-file] file [ revision ] + print STDERR "Usage: ${\basename $0} [-s] [-S revs-file] file [ revision ] -l, --long Show long rev (Defaults off) -t, --time @@ -23,7 +24,7 @@ sub usage() { Use revs from revs-file instead of calling git-rev-list -h, --help This message. -'; +"; exit(1); } @@ -35,7 +36,7 @@ my $rc = GetOptions( "long|l" => \$longrev, "help|h" => \$help, "rename|r" => \$rename, "rev-file|S=s" => \$rev_file); -if (!$rc or $help) { +if (!$rc or $help or !@ARGV) { usage(); } @@ -208,6 +209,9 @@ sub find_parent_renames { while (my $change = <$patch>) { chomp $change; my $filename = <$patch>; + if (!defined $filename) { + next; + } chomp $filename; if ($change =~ m/^[AMD]$/ ) {