From: Joey Hess Date: Thu, 24 Dec 2009 17:23:27 +0000 (-0500) Subject: Allow empty sections to be used in mrconfig files. X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/2cb02ac8d550b1335c547bc59d2af249c3c08e1f?ds=inline Allow empty sections to be used in mrconfig files. Previously the parser only added a section if it had at least one configuration line. With this change, an empty section cannot be checked out by mr, but it can be updated, etc. --- diff --git a/debian/changelog b/debian/changelog index ca820b5..b5d731f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ mr (0.47) UNRELEASED; urgency=low * Pass -L to curl to allow it to follow redirects when bootstrapping. (Pavel Avgustinov) + * Allow empty sections to be used in mrconfig files. -- Joey Hess Sun, 13 Dec 2009 13:04:53 -0500 diff --git a/mr b/mr index 0bf6655..7224a04 100755 --- a/mr +++ b/mr @@ -1037,6 +1037,12 @@ sub loadconfig { } } $section=expandenv($section) if $trusted; + if ($section ne 'ALIAS' && + ! exists $config{$dir}{$section} && + exists $config{$dir}{DEFAULT}) { + # copy in defaults + $config{$dir}{$section}={ %{$config{$dir}{DEFAULT}} }; + } } elsif (/^(\w+)\s*=\s*(.*)/) { my $parameter=$1; @@ -1073,12 +1079,6 @@ sub loadconfig { if (! defined $section) { die "$f line $.: parameter ($parameter) not in section\n"; } - if ($section ne 'ALIAS' && - ! exists $config{$dir}{$section} && - exists $config{$dir}{DEFAULT}) { - # copy in defaults - $config{$dir}{$section}={ %{$config{$dir}{DEFAULT}} }; - } if ($section eq 'ALIAS') { $alias{$parameter}=$value; }