about summary refs log tree commit homepage
path: root/lib/PublicInbox/LEI.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-24 05:42:09 +0000
committerEric Wong <e@80x24.org>2023-09-24 18:56:05 +0000
commite3455d2f3b100a13cbf7cfe6b36619096a2c4e8a (patch)
tree7422e59993cf9dfe53565ca7a69818b2f9493bc5 /lib/PublicInbox/LEI.pm
parent89ded2496df4b638aa35c93a1a48f572261d2a02 (diff)
downloadpublic-inbox-e3455d2f3b100a13cbf7cfe6b36619096a2c4e8a.tar.gz
2020-2021 were bad times and I somehow got deluded into
believing git-config(1) would always succeed :x
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r--lib/PublicInbox/LEI.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 368f9357..a6d92eec 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -776,9 +776,8 @@ EOM
                 /\A([^=\.]+\.[^=]+)(?:=(.*))?\z/ or return fail($self, <<EOM);
 `-c $_' is not of the form -c <name>=<value>'
 EOM
-                my $name = $1;
-                my $value = $2 // 1;
-                _config($self, '--add', $name, $value);
+                my ($name, $value) = ($1, $2 // 1);
+                _config($self, '--add', $name, $value) or return;
                 if (defined(my $v = $tmp->{$name})) {
                         if (ref($v) eq 'ARRAY') {
                                 push @$v, $value;
@@ -894,13 +893,17 @@ sub _lei_store ($;$) {
         };
 }
 
+# returns true on success, undef
+# argv[0] eq `+e' means errors do not ->fail # (like `sh +e')
 sub _config {
         my ($self, @argv) = @_;
+        my $err_ok = ($argv[0] // '') eq '+e' ? shift(@argv) : undef;
         my %env = (%{$self->{env}}, GIT_CONFIG => undef);
         my $cfg = _lei_cfg($self, 1);
         my $cmd = [ qw(git config -f), $cfg->{'-f'}, @argv ];
         my %rdr = map { $_ => $self->{$_} } (0..2);
         waitpid(spawn($cmd, \%env, \%rdr), 0);
+        $? == 0 ? 1 : ($err_ok ? undef : fail($self, $?));
 }
 
 sub lei_daemon_pid { puts shift, $$ }