Skip to content

Commit fc55bc8

Browse files
Merge pull request #409 from ericbn/git-config
Only call sub git_config_raw once
2 parents e526f6b + b0d5af2 commit fc55bc8

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

diff-so-fancy

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -434,30 +434,19 @@ sub boolean {
434434
}
435435
}
436436

437-
# Memoize getting the git config
437+
# Get the git config
438438
sub git_config_raw {
439-
state $static_config;
440-
441-
if ($static_config) {
442-
# If we already have the config return that
443-
return $static_config;
444-
}
445-
446439
my $cmd = "git config --list";
447440
my @out = `$cmd`;
448441

449-
$static_config = \@out;
450-
451442
return \@out;
452443
}
453444

454-
# Fetch a textual item from the git config
445+
# Memoize fetching a textual item from the git config
455446
sub git_config {
456447
my $search_key = lc($_[0] || "");
457448
my $default_value = lc($_[1] || "");
458449

459-
my $out = git_config_raw();
460-
461450
# If we're in a unit test, use the default (don't read the users config)
462451
if (in_unit_test()) {
463452
return $default_value;
@@ -472,6 +461,8 @@ sub git_config {
472461
print "Parsing git config\n";
473462
}
474463

464+
my $out = git_config_raw();
465+
475466
foreach my $line (@$out) {
476467
if ($line =~ /=/) {
477468
my ($key,$value) = split("=",$line,2);

0 commit comments

Comments
 (0)