From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id D57FD1F404 for ; Fri, 30 Mar 2018 13:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbeC3NQH (ORCPT ); Fri, 30 Mar 2018 09:16:07 -0400 Received: from mout.gmx.net ([212.227.17.20]:36425 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751862AbeC3NQF (ORCPT ); Fri, 30 Mar 2018 09:16:05 -0400 Received: from [192.168.0.129] ([37.201.195.115]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0M7m0a-1eg5g442am-00vP2f; Fri, 30 Mar 2018 15:15:49 +0200 Date: Fri, 30 Mar 2018 15:15:47 +0200 (DST) From: Johannes Schindelin X-X-Sender: virtualbox@dscho.gitforwindows.org To: Jeff King cc: git@vger.kernel.org, Junio C Hamano , Thomas Rast , Phil Haack , =?UTF-8?Q?=C3=86var_Arnfj=C3=B6r=C3=B0_Bjarmason?= , Stefan Beller , Jason Frey , Philip Oakley Subject: Re: [PATCH 9/9] git_config_set: reuse empty sections In-Reply-To: <20180329215038.GI2939@sigill.intra.peff.net> Message-ID: References: <29868fec2606f5f6aa1c5de2928580f2ca24e6e2.1522336130.git.johannes.schindelin@gmx.de> <20180329215038.GI2939@sigill.intra.peff.net> User-Agent: Alpine 2.21.1 (DE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xwVYO3IRNRKfaBa/ sREo7GVnLOP/zzrPPB3SIGTptyAhkcdUxvBP8Bn8qS4mO+91h6QWgebtkPiDyx3wtV/P+O4Zp OaUFDFtBA+VfTtwQvDKHMgZokIr93apRRidVjm73qiLjRbWtnF5yTJzpEBl8i7JGW5ICBu3 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Peff, On Thu, 29 Mar 2018, Jeff King wrote: > On Thu, Mar 29, 2018 at 05:19:09PM +0200, Johannes Schindelin wrote: > > > It can happen quite easily that the last setting in a config section is > > removed, and to avoid confusion when there are comments in the config > > about that section, we keep a lone section header, i.e. an empty > > section. > > > > The code to add new entries in the config tries to be cute by reusing > > the parsing code that is used to retrieve config settings, but that > > poses the problem that the latter use case does *not* care about empty > > sections, therefore even the former user case won't see them. > > > > Fix this by introducing a mode where the parser reports also empty > > sections (with a trailing '.' as tell-tale), and then using that when > > adding new config entries. > > Heh, so it seems we are partway to the "event-stream" suggestion I made > earlier. I agree this is the right way to approach this problem. > > I wondered if we allow keys to end in ".", but it seems that we don't. > > > diff --git a/config.c b/config.c > > index eb1e0d335fc..b04c40f76bc 100644 > > --- a/config.c > > +++ b/config.c > > @@ -653,13 +653,15 @@ static int get_base_var(struct strbuf *name) > > } > > } > > > > -static int git_parse_source(config_fn_t fn, void *data) > > +static int git_parse_source(config_fn_t fn, void *data, > > + int include_section_headers) > > We already have a "struct config_options", but we do a terrible job of > passing it around (since it only impacts the include stuff right now, > and that all gets handled at a very outer level). > > Rather than plumb this one int through everywhere, should we add it to > that struct and plumb the struct through? Yesss! Again, thank you so much for this really valuable review. This is even better than what I hoped for. Ciao, Dscho