Git.pm: Handle failed commands' output
[gitweb.git] / git-fmt-merge-msg.perl
index be2a48cf65949ba16b354e476dd39f5c334f1b25..f86231e14b0bf0d16ae3ac7978b824b3a994d359 100755 (executable)
@@ -7,6 +7,7 @@
 
 use strict;
 use Git;
+use Error qw(:try);
 
 my $repo = Git->repository();
 
@@ -31,7 +32,17 @@ sub andjoin {
 }
 
 sub repoconfig {
-       my ($val) = $repo->command_oneline('repo-config', '--get', 'merge.summary');
+       my $val;
+       try {
+               $val = $repo->command_oneline('repo-config', '--get', 'merge.summary');
+       } catch Git::Error::Command with {
+               my ($E) = shift;
+               if ($E->value() == 1) {
+                       return undef;
+               } else {
+                       throw $E;
+               }
+       };
        return $val;
 }