about summary refs log tree commit homepage
path: root/t/config.t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-17 06:07:10 +0000
committerEric Wong <e@yhbt.net>2020-07-17 18:54:53 +0000
commitd87dd0e6795870439422ee4f0039d0d76d1974b3 (patch)
tree6f548bc6a49623cb183e387ba12d39a1e5f3ce3f /t/config.t
parent95d17835014ece9d53791a07ddf294ad2986abf9 (diff)
downloadpublic-inbox-d87dd0e6795870439422ee4f0039d0d76d1974b3.tar.gz
"\n" and other characters requiring quoting and/or escaping in
in $GIT_DIR/objects/info/alternates was not supported in git 2.11
and earlier; nor does it seem supported at all in libgit2.

This will allow us to support sharing git-cat-file or similar
endpoints across multiple inboxes via alternates.

This breaks an existing use case for anybody wacky
enough to put `\n' in the `inboxdir' pathname; but I doubt
this affects anybody.
Diffstat (limited to 't/config.t')
-rw-r--r--t/config.t16
1 files changed, 13 insertions, 3 deletions
diff --git a/t/config.t b/t/config.t
index ad543ad3..d7fd9446 100644
--- a/t/config.t
+++ b/t/config.t
@@ -10,13 +10,23 @@ my ($tmpdir, $for_destroy) = tmpdir();
 
 {
         PublicInbox::Import::init_bare($tmpdir);
-        my @cmd = ('git', "--git-dir=$tmpdir", qw(config foo.bar), "hi\nhi");
+        my $inboxdir = "$tmpdir/new\nline";
+        my @cmd = ('git', "--git-dir=$tmpdir",
+                qw(config publicinbox.foo.inboxdir), $inboxdir);
         is(xsys(@cmd), 0, "set config");
 
         my $tmp = PublicInbox::Config->new("$tmpdir/config");
 
-        is("hi\nhi", $tmp->{"foo.bar"}, "config read correctly");
-        is("true", $tmp->{"core.bare"}, "used --bare repo");
+        is($tmp->{'publicinbox.foo.inboxdir'}, $inboxdir,
+                'config read correctly');
+        is($tmp->{'core.bare'}, 'true', 'init used --bare repo');
+
+        my @warn;
+        local $SIG{__WARN__} = sub { push @warn, @_ };
+        $tmp = PublicInbox::Config->new("$tmpdir/config");
+        is($tmp->lookup_name('foo'), undef, 'reject invalid inboxdir');
+        like("@warn", qr/^E:.*must not contain `\\n'/sm,
+                'warned about newline');
 }
 
 {