From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C6DCE20A1E; Tue, 25 Dec 2018 03:44:57 +0000 (UTC) Date: Tue, 25 Dec 2018 03:44:57 +0000 From: Eric Wong To: meta@public-inbox.org Cc: "Eric W. Biederman" Subject: [PATCH] init: do not set publicinbox.$NAME.indexlevel by default Message-ID: <20181225034457.v6oukmmh6rn25gmj@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline List-Id: It is redundant to set default values in the public-inbox config file. Lets not clutter up users' screens when they view or edit the config file. --- script/public-inbox-init | 6 ++++-- t/init.t | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/script/public-inbox-init b/script/public-inbox-init index 5e961c8..1aec799 100755 --- a/script/public-inbox-init +++ b/script/public-inbox-init @@ -76,7 +76,6 @@ if (-e $pi_config) { } } close $fh or die "failed to close $pi_config_tmp: $!\n"; -$indexlevel ||= 'full'; my $pfx = "publicinbox.$name"; my @x = (qw/git config/, "--file=$pi_config_tmp"); @@ -125,7 +124,10 @@ foreach my $addr (@address) { } x(@x, "$pfx.url", $http_url); x(@x, "$pfx.mainrepo", $mainrepo); -x(@x, "$pfx.indexlevel", $indexlevel); + +if (defined($indexlevel)) { + x(@x, "$pfx.indexlevel", $indexlevel); +} rename $pi_config_tmp, $pi_config or die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n"; diff --git a/t/init.t b/t/init.t index 59f5481..182d065 100644 --- a/t/init.t +++ b/t/init.t @@ -32,6 +32,8 @@ sub quiet_fail { qw(http://example.com/blist blist@example.com)); is(system(@cmd), 0, 'public-inbox-init OK'); + is(read_indexlevel('blist'), '', 'indexlevel unset by default'); + ok(-e $cfgfile, "config exists, now"); is(system(@cmd), 0, 'public-inbox-init OK (idempotent)'); @@ -64,10 +66,26 @@ SKIP: { is(system(@cmd), 0, 'public-inbox-init is idempotent'); ok(! -d "$tmpdir/public-inbox" && !-d "$tmpdir/objects", 'idempotent invocation w/o -V2 does not make inbox v1'); + is(read_indexlevel('v2list'), '', 'indexlevel unset by default'); @cmd = (pi_init, 'v2list', "-V1", "$tmpdir/v2list", qw(http://example.com/v2list v2list@example.com)); quiet_fail(\@cmd, 'initializing V2 as V1 fails'); + + foreach my $lvl (qw(medium basic)) { + @cmd = (pi_init, "v2$lvl", '-V2', '-L', $lvl, + "$tmpdir/v2$lvl", "http://example.com/v2$lvl", + "v2$lvl\@example.com"); + is(system(@cmd), 0, "-init -L $lvl"); + is(read_indexlevel("v2$lvl"), $lvl, "indexlevel set to '$lvl'"); + } } done_testing(); + +sub read_indexlevel { + my ($inbox) = @_; + local $ENV{GIT_CONFIG} = "$ENV{PI_DIR}/config"; + chomp(my $lvl = `git config publicinbox.$inbox.indexlevel`); + $lvl; +}