[Bps-public-commit] Config-GitLike branch, master, updated. 1.16-7-g8e5fbea

Alex Vandiver alexmv at bestpractical.com
Sun Jul 16 21:33:34 EDT 2017


The branch, master has been updated
       via  8e5fbeab14cfd0a82d9a1473237c5f53572ae48b (commit)
       via  f911879a41a7edcbcf9c2fd0b85f4c4fc5f11025 (commit)
      from  ae3b8f2b1ffbd816c5119a85d8a528f37219b03b (commit)

Summary of changes:
 lib/Config/GitLike.pm | 2 ++
 t/casing.t            | 4 ++++
 2 files changed, 6 insertions(+)

- Log -----------------------------------------------------------------
commit f911879a41a7edcbcf9c2fd0b85f4c4fc5f11025
Author: David E. Wheeler <david at justatheory.com>
Date:   Mon Aug 19 12:25:36 2013 +0200

    Throw an error when get() is passed no section.
    
    Reported in theory/sqitch#110. It was doing this:
    
        t/sqitch config --get user
        Use of uninitialized value $section in lc at lib/Config/GitLike.pm line 658.
    
    But that is not what Git does:
    
        > git config --get user
        error: key does not contain a section: user
    
    This patch makes Config::GitLike behave a bit more like Git in this respect.

diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 15de2fc..b33be36 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -654,6 +654,8 @@ sub canonical_case {
     my $self = shift;
     my ($key) = @_;
     my ($section, $subsection, $name) = _split_key($key);
+    die "No section given in key: $key\n" unless $section;
+
     return join( '.',
         grep { defined } (lc $section, $subsection, lc $name),
     );
diff --git a/t/casing.t b/t/casing.t
index c589b5a..da370c6 100644
--- a/t/casing.t
+++ b/t/casing.t
@@ -39,6 +39,10 @@ is $config->original_key( 'core.foobar' ), "core.FooBar",
 is $config->original_key( 'core.FOObar' ), "core.FooBar",
     "Find original case when asked in different case";
 
+eval { $config->get( key => 'core') };
+ok my $err = $@, 'Should get an error when no section passed to get().';
+like $err, qr/No section given in key: core/,
+    'The missing section error should be correct';
 
 my $other_filename = File::Spec->catfile( $config_dirname, 'other' );
 $config->set(

commit 8e5fbeab14cfd0a82d9a1473237c5f53572ae48b
Merge: ae3b8f2 f911879
Author: Alex Vandiver <alex at chmrr.net>
Date:   Sun Jul 16 18:33:18 2017 -0700

    Merge remote-tracking branch 'prs/10'


-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list