workaround older git without "commit-tree -m"
authorEric Wong <normalperson@yhbt.net>
Sun, 20 Apr 2014 23:49:17 +0000 (23:49 +0000)
committerEric Wong <normalperson@yhbt.net>
Mon, 21 Apr 2014 00:04:23 +0000 (00:04 +0000)
We need to support older git versions lying around.
Some versions broke argument ordering, too.

lib/Ssoma/Git.pm

index 5f5702bbcaf7cf281c0fe6aa1085e5e61b0725aa..22118932c8043c99038dfa085359069a430fe4b8 100644 (file)
@@ -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);