]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Rcs/git.pm
Add test for old versions of git that don't support --cleanup=verbatim, and munge...
[ikiwiki.git] / IkiWiki / Rcs / git.pm
index ecf560d0ba8dc09edf2c48da59eddd0cfe864143..1fa9188aa3c29fbfa35065382bb0c92ef5eb25b8 100644 (file)
@@ -336,11 +336,23 @@ sub rcs_commit_staged ($$$) {
                $ENV{GIT_AUTHOR_EMAIL}="$u\@web";
        }
 
+       $message = 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 = 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});
                }