X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-annotate.perl;h=08d479f4b9b0d4911543ce35714bef13adbb8d20;hb=cd1333db4f41c44930884176601a8f7725fdd0fa;hp=f9c2c6caf5d2127d59cfd91d7bbecc2bc1466daf;hpb=6be65bbc958e8d7c57bc81ae7035119b8b1afbab;p=git.git diff --git a/git-annotate.perl b/git-annotate.perl index f9c2c6ca..08d479f4 100755 --- a/git-annotate.perl +++ b/git-annotate.perl @@ -15,6 +15,8 @@ sub usage() { print STDERR 'Usage: ${\basename $0} [-s] [-S revs-file] file [ revision ] -l, --long Show long rev (Defaults off) + -t, --time + Show raw timestamp (Defaults off) -r, --rename Follow renames (Defaults on). -S, --rev-file revs-file @@ -26,12 +28,13 @@ sub usage() { exit(1); } -our ($help, $longrev, $rename, $starting_rev, $rev_file) = (0, 0, 1); +our ($help, $longrev, $rename, $rawtime, $starting_rev, $rev_file) = (0, 0, 1); my $rc = GetOptions( "long|l" => \$longrev, + "time|t" => \$rawtime, "help|h" => \$help, "rename|r" => \$rename, - "rev-file|S" => \$rev_file); + "rev-file|S=s" => \$rev_file); if (!$rc or $help) { usage(); } @@ -174,7 +177,8 @@ sub git_rev_list { my $revlist; if ($rev_file) { - open($revlist, '<' . $rev_file); + open($revlist, '<' . $rev_file) + or die "Failed to open $rev_file : $!"; } else { $revlist = open_pipe("git-rev-list","--parents","--remove-empty",$rev,"--",$file) or die "Failed to exec git-rev-list: $!"; @@ -304,6 +308,12 @@ sub _git_diff_parse { } $ri++; + } elsif (m/^\\/) { + ; + # Skip \No newline at end of file. + # But this can be internationalized, so only look + # for an initial \ + } else { if (substr($_,1) ne get_line($slines,$ri) ) { die sprintf("Line %d (%d) does not match:\n|%s\n|%s\n%s => %s\n", @@ -404,8 +414,10 @@ sub git_commit_info { } sub format_date { + if ($rawtime) { + return $_[0]; + } my ($timestamp, $timezone) = split(' ', $_[0]); - return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($timestamp)); }