This is more interesting than just using 'mda' all the time, but it's
harder to setup proper quoting around the message without using
third-party Perl modules (e.g. IPC::Run or String::ShellQuote). This
proof-of-concept patch just assumes the subject doesn't contain
single-quotes ('). This patch also doesn't handle the empty/missing
subject case, which should probably fall back to '<no subject>' or
some such.
I'm fine dropping support for older Gits here, and just using the -m
option to commit-tree. That landed with
96b8d93a (commit-tree: teach
-m/-F options to read logs from elsewhere, 2011-11-09) in Git v1.7.9,
which was released over 2.5 years ago on 2012-01-27.
It would also be useful (I think) to set the GIT_AUTHOR_NAME,
GIT_AUTHOR_EMAIL, and GIT_AUTHOR_DATE environment variables from the
message header before committing. I know how to do that using
Python's subprocess module, but I don't know the Perl incantation.
my @cmd = qw/git commit-tree/;
push @cmd, $tree;
push @cmd, '-p', $parent if $parent;
+ push @cmd, '-m', "'$message'";
- # 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));
+ my $commit = $self->qx_sha1(join(' ', @cmd));
# update the ref
@cmd = (qw/git update-ref/, $ref, $commit);
my $id = $git->simple_to_blob($simple);
$gii->update('100644', $id, $path);
}
- $git->commit_index($gii, 0, $ref, "mda");
+ my $subject = $simple->header("Subject");
+ $git->commit_index($gii, 0, $ref, $subject);
}
# the main entry point takes an Email::Simple object