about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiConfig.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-24 05:42:12 +0000
committerEric Wong <e@80x24.org>2023-09-24 18:56:07 +0000
commitb4b22d40c52584836d7c0c97a513dfac1c12fbee (patch)
tree5ce2d2e96009d4615abc8127cfa6957d04294fb9 /lib/PublicInbox/LeiConfig.pm
parente11420993bf3b9e630f2797e07d8f6abd8d74e28 (diff)
downloadpublic-inbox-b4b22d40c52584836d7c0c97a513dfac1c12fbee.tar.gz
Our previous use of lei->cfg_dump was wrong as the extra arg was
never supported.  Instead, we need to capture the output of
`git config' and send it to the pager if ->cfg_dump fails.  We'll
also add a note to the user to quit the pager to continue.
Diffstat (limited to 'lib/PublicInbox/LeiConfig.pm')
-rw-r--r--lib/PublicInbox/LeiConfig.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiConfig.pm b/lib/PublicInbox/LeiConfig.pm
index 23be9aaf..fd4b0eca 100644
--- a/lib/PublicInbox/LeiConfig.pm
+++ b/lib/PublicInbox/LeiConfig.pm
@@ -4,6 +4,8 @@ package PublicInbox::LeiConfig;
 use strict;
 use v5.10.1;
 use PublicInbox::PktOp;
+use Fcntl qw(SEEK_SET);
+use autodie qw(open seek);
 
 sub cfg_do_edit ($;$) {
         my ($self, $reason) = @_;
@@ -22,8 +24,14 @@ sub cfg_do_edit ($;$) {
 sub cfg_edit_done { # PktOp
         my ($self) = @_;
         eval {
-                my $cfg = $self->{lei}->cfg_dump($self->{-f}, $self->{lei}->{2})
-                        // return cfg_do_edit($self, "\n");
+                open my $fh, '+>', undef or die "open($!)";
+                my $cfg = do {
+                        local $self->{lei}->{2} = $fh;
+                        $self->{lei}->cfg_dump($self->{-f});
+                } or do {
+                        seek($fh, 0, SEEK_SET);
+                        return cfg_do_edit($self, do { local $/; <$fh> });
+                };
                 $self->cfg_verify($cfg) if $self->can('cfg_verify');
         };
         $self->{lei}->fail($@) if $@;