aboutsummaryrefslogtreecommitdiff
path: root/git2cl
diff options
context:
space:
mode:
Diffstat (limited to 'git2cl')
-rwxr-xr-xgit2cl30
1 files changed, 29 insertions, 1 deletions
diff --git a/git2cl b/git2cl
index 9248895..534b78a 100755
--- a/git2cl
+++ b/git2cl
@@ -10,6 +10,8 @@
# - skip "merge branch" statements as they don't
# have information about files (i.e. we never
# go into $state 2)
+# - behaves like a pipe/filter if input is given from the CLI
+# else it calls git log by itself
#
# The functions mywrap, last_line_len, wrap_log_entry are derived from
# the cvs2cl tool, see <http://www.red-bean.com/cvs2cl/>:
@@ -34,6 +36,7 @@
use strict;
use POSIX qw(strftime);
use Text::Wrap qw(wrap);
+use FileHandle;
use constant EMPTY_LOG_MESSAGE => '*** empty log message ***';
@@ -53,6 +56,16 @@ my %month = (
'Nov'=>10,
'Dec'=>11,
);
+
+my $fh = new FileHandle;
+
+sub key_ready
+{
+ my ($rin, $nfd);
+ vec($rin, fileno(STDIN), 1) = 1;
+ return $nfd = select($rin, undef, undef, 0);
+}
+
sub strptime {
my $str = shift;
return undef if not defined $str;
@@ -275,7 +288,22 @@ my $done = 0;
$state = 0;
-while (my $_l = <>) {
+# if reading from STDIN, we assume that we are
+# getting git log as input
+if (key_ready())
+{
+
+ #my $dummyfh; # don't care about writing
+ #($fh,$dummyfh) = FileHandle::pipe;
+ $fh->fdopen(*STDIN, 'r');
+}
+else
+{
+ $fh->open("LC_ALL=C git log --pretty --numstat --summary|")
+ or die("Cannot execute git log...$!\n");
+}
+
+while (my $_l = <$fh>) {
#print STDERR "debug ($state, " . (@date ? (strftime "%Y-%m-%d", @date) : "") . "): `$_'\n";
if ($state == 0) {
if ($_l =~ m,^Author: (.*),) {