X-Git-Url: https://git.octo.it/?p=git.git;a=blobdiff_plain;f=git-annotate.perl;h=a6a7a482cdcf34e3a1d545c7d5deab599a7c0d2f;hp=feea0a2d81c1d4841fe46d230a0ebfe87a4f82f2;hb=162f41292167a800432fc6bbacfcd9f93a90b0c8;hpb=3bcd59a546333ae355c87577ba63f8dccd50a519 diff --git a/git-annotate.perl b/git-annotate.perl index feea0a2d..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 @@ -20,10 +21,10 @@ sub usage() { -r, --rename Follow renames (Defaults on). -S, --rev-file revs-file - use revs from revs-file instead of calling git-rev-list + 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]$/ ) {