]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/git.pm
nice message if someone tries to revert a merge commit
[ikiwiki.git] / IkiWiki / Plugin / git.pm
index 892b711d8e871b3a24ade2f5e13287d88f06140c..f5101d904012b8472c1cf77d143ee218f0e32f59 100644 (file)
@@ -848,8 +848,20 @@ sub rcs_preprevert ($) {
        # in order to see all changes.
        my ($subdir, $rootdir) = git_find_root();
        $git_dir=$rootdir;
-       return git_parse_changes(git_commit_info($sha1, 1));
+       my @commits=git_commit_info($sha1, 1);
        $git_dir=undef;
+
+       if (! @commits) {
+               error "unknown commit"; # just in case
+       }
+
+       # git revert will fail on merge commits. Add a nice message.
+       if (exists $commits[0]->{parents} &&
+           @{$commits[0]->{parents}} > 1) {
+               error gettext("you are not allowed to revert a merge");
+       }
+
+       return git_parse_changes(@commits);
 }
 
 sub rcs_revert ($) {