} #}}}
sub checkconfig () { #{{{
- if (! defined $config{diffurl}) {
- $config{diffurl}="";
- }
if (! defined $config{gitorigin_branch}) {
$config{gitorigin_branch}="origin";
}
sub getsetup () { #{{{
return
+ plugin => {
+ safe => 0, # rcs plugin
+ rebuild => undef,
+ },
git_wrapper => {
type => "string",
example => "/git/wiki.git/hooks/post-update",
- description => "git post-update executable to generate",
+ description => "git hook to generate",
safe => 0, # file
rebuild => 0,
},
my $sha1_to = shift(@tmp);
my $status = shift(@tmp);
+ # git does not output utf-8 filenames, but instead
+ # double-quotes them with the utf-8 characters
+ # escaped as \nnn\nnn.
if ($file =~ m/^"(.*)"$/) {
($file=$1) =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
}
$file =~ s/^\Q$prefix\E//;
if (length $file) {
push @{ $ci{'details'} }, {
- 'file' => decode_utf8($file),
+ 'file' => decode("utf8", $file),
'sha1_from' => $sha1_from[0],
'sha1_to' => $sha1_to,
};
$ENV{GIT_AUTHOR_EMAIL}="$u\@web";
}
+ $message = IkiWiki::possibly_foolish_untaint($message);
+ my @opts;
+ if ($message !~ /\S/) {
+ # Force git to allow empty commit messages.
+ # (If this version of git supports it.)
+ my ($version)=`git --version` =~ /git version (.*)/;
+ if ($version ge "1.5.4") {
+ push @opts, '--cleanup=verbatim';
+ }
+ else {
+ $message.=".";
+ }
+ }
+ push @opts, '-q';
# git commit returns non-zero if file has not been really changed.
# so we should ignore its exit status (hence run_or_non).
- $message = IkiWiki::possibly_foolish_untaint($message);
- if (run_or_non('git', 'commit', '--cleanup=verbatim',
- '-q', '-m', $message)) {
+ if (run_or_non('git', 'commit', @opts, '-m', $message)) {
if (length $config{gitorigin_branch}) {
run_or_cry('git', 'push', $config{gitorigin_branch});
}
foreach my $detail (@{ $ci->{'details'} }) {
my $file = $detail->{'file'};
- my $diffurl = $config{'diffurl'};
+ my $diffurl = defined $config{'diffurl'} ? $config{'diffurl'} : "";
$diffurl =~ s/\[\[file\]\]/$file/go;
$diffurl =~ s/\[\[sha1_parent\]\]/$ci->{'parent'}/go;
$diffurl =~ s/\[\[sha1_from\]\]/$detail->{'sha1_from'}/go;