Skip to content

Commit 3224f53

Browse files
Make sure we have a key AND a value
1 parent 866e1cd commit 3224f53

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

diff-so-fancy

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,17 @@ sub get_git_config_hash {
367367
my %hash;
368368
foreach my $line (@$out) {
369369
my ($key,$value) = split("=",$line,2);
370-
$value =~ s/\s+$//;
371-
my @path = split(/\./,$key);
372370

373-
my $last = pop @path;
374-
my $p = \%hash;
375-
$p = $p->{$_} ||= {} for @path;
376-
$p->{$last} = $value;
371+
if ($key && $value) {
372+
$value =~ s/\s+$//;
373+
my @path = split(/\./,$key);
374+
my $last = pop @path;
375+
my $p = \%hash;
376+
377+
# Build the tree for each section
378+
$p = $p->{$_} ||= {} for @path;
379+
$p->{$last} = $value;
380+
}
377381
}
378382

379383
return \%hash;

0 commit comments

Comments
 (0)