From a722d9aa28c19d82b74ccde6d94e6bdde9917f0c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 Sep 2019 20:59:30 +0000 Subject: config: use NUL-delimited git-config(1) output This allows us to deal with newlines in config values, since git-config(1) acquired "-z" support in git v1.5.3. I'm not sure if it's actually useful in our case, but maybe some multi-line texts could be added. And newlines in path names are super useful! --- lib/PublicInbox/Config.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index ef277c40..4fcb20d2 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -151,14 +151,14 @@ sub git_config_dump { my ($file) = @_; my (%section_seen, @section_order); return {} unless -e $file; - my @cmd = (qw/git config/, "--file=$file", '-l'); + my @cmd = (qw/git config -z -l/, "--file=$file"); my $cmd = join(' ', @cmd); my $fh = popen_rd(\@cmd) or die "popen_rd failed for $file: $!\n"; my %rv; - local $/ = "\n"; + local $/ = "\0"; while (defined(my $line = <$fh>)) { chomp $line; - my ($k, $v) = split(/=/, $line, 2); + my ($k, $v) = split(/\n/, $line, 2); my ($section) = ($k =~ /\A(\S+)\.[^\.]+\z/); unless (defined $section_seen{$section}) { -- cgit v1.2.3-24-ge0c7