From: Eric Wong Date: Sun, 20 Apr 2014 23:49:17 +0000 (+0000) Subject: workaround older git without "commit-tree -m" X-Git-Tag: v0.0.0~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ef7ddcc92c33fc61eb9e97e51c544dd3685db006;p=ssoma-mda.git workaround older git without "commit-tree -m" We need to support older git versions lying around. Some versions broke argument ordering, too. --- diff --git a/lib/Ssoma/Git.pm b/lib/Ssoma/Git.pm index 5f5702b..2211893 100644 --- a/lib/Ssoma/Git.pm +++ b/lib/Ssoma/Git.pm @@ -263,10 +263,13 @@ sub commit_index { } # make the commit - my @cmd = (qw/git commit-tree -m/, $message); - push @cmd, '-p', $parent if $parent; + my @cmd = qw/git commit-tree/; push @cmd, $tree; - my $commit = $self->qx_sha1(join(' ', @cmd)); + push @cmd, '-p', $parent if $parent; + + # git commit-tree -m didn't work in older git versions + $message =~ /\A\w+\z/ or die "message must be \\w+ only\n"; + my $commit = $self->qx_sha1("echo $message |". join(' ', @cmd)); # update the ref @cmd = (qw/git update-ref/, $ref, $commit);