From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-10.6 required=3.0 tests=AWL,BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 165F81F542 for ; Wed, 31 May 2023 20:54:29 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=b5kOb3a0; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjEaUyZ (ORCPT ); Wed, 31 May 2023 16:54:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjEaUyX (ORCPT ); Wed, 31 May 2023 16:54:23 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AA9129 for ; Wed, 31 May 2023 13:54:21 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-25669acf204so4202083a91.2 for ; Wed, 31 May 2023 13:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685566461; x=1688158461; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ba6+NXj1PVK7O1EbyJCCooILB25SraFQf9TeRhP7+Aw=; b=b5kOb3a0pI4PbF5IlzM6HdhX6HCRc6BKY7+SKnC6lWhPhfrl/+WqzKe4wgNvA4J9i+ N9nPE+FchiubDZSR/N0U0OZfyKOojbp+yL9mA/RFFIHOHOzQkPN1LANDT6C0g3Xuuv32 Dcrpf3TtYM3/7EGR30hEjevG3snDZ/uFtDg/Fxj4YhIgq1bV2luZIktY2teJp49sheAX 3YL1JB9xP/9POf/JubrIMKnIR/rC06AH8A5SOtszuI8TsNBmffJ9YnpUz9zWZa3es7hq +vJlrw3kpEnxub6q8QzdcfqiCYqMlFSQTZE02R+NRu3lAz0srnMvYrI1i/p26nlAngJM eIXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685566461; x=1688158461; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ba6+NXj1PVK7O1EbyJCCooILB25SraFQf9TeRhP7+Aw=; b=aRfr/EOPW+I0MpRZtP2uQfQF3FzzWiqKyu0HXdbjK8K5tTnm1m7IsJF5ImtAw7CIyG boXBMKCyX0PG+vywyE5Ux4F1LjfZuX5oLE6729uqmdvImKxltGNsHvYJWbjwVyU2XAU4 BsiLciK/05fQybIZYHi+XNUZBRfwT4SWHlXr8wmceO9G0PR+4txV/EZvmpfeEcGojsAW //WGtM1qREgHZJnLHKRIwpFr1qIYusIvfJ9+P0IK/lAWOsPTaAiOTYycv7CxHfclYGln 2lNPpc+osU1HIefIQ4SIkCmsFo9ofmfDiF4S2CMyctmn2MeIT/2LN+oWu+Jt2SEb2Cls nYag== X-Gm-Message-State: AC+VfDy3b577GbgTlh1P1P+pT6FZCX6sW9EK8M3ZYEgVRHzy+U59cmvb KTDwuYGSPi9Ezm9mJKtx3ovCi7YoWBwwvA== X-Google-Smtp-Source: ACHHUZ4Ay1PlsPn9DaQk8sYag0Cms2csfUQcmmmxvBwsGzNPhLkA5hLGokZLxqcxpNVFvTsXDITbW/0cUVPAyw== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:3a07]) (user=chooglen job=sendgmr) by 2002:a17:90b:1107:b0:253:3118:1ba1 with SMTP id gi7-20020a17090b110700b0025331181ba1mr1559861pjb.3.1685566461071; Wed, 31 May 2023 13:54:21 -0700 (PDT) Date: Wed, 31 May 2023 13:54:12 -0700 In-Reply-To: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH v2 1/3] config: use gitdir to get worktree config From: Glen Choo To: Victoria Dye via GitGitGadget , git@vger.kernel.org Cc: derrickstolee@github.com, gitster@pobox.com, Victoria Dye Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "Victoria Dye via GitGitGadget" writes: > Finally, add tests to 't3007-ls-files-recurse-submodules.sh' to verify the > corrected config is loaded. Use 'ls-files' to test this because, unlike some > other '--recurse-submodules' commands, 'ls-files' parses the config of the > submodule in the same process as the superproject (via 'show_submodule()' -> > 'repo_read_index()' -> 'prepare_repo_settings()'). As a result, > 'the_repository' points to the config of the superproject but the > commondir/gitdir in the config sequence will be that of the submodule, > providing the exact scenario needed to verify this patch. > > The first test ('--recurse-submodules parses submodule repo config') checks > that the submodule's *repo* config is read when running 'ls-files' on the > superproject; this confirms already-working behavior, serving as a reference > for how worktree config parsing should behave. The second test > ('--recurse-submodules parses submodule worktree config') tests the same > scenario as the previous but instead using the *worktree* config, > demonstrating the corrected behavior. The 'test_config' helper is extended > for this case so that it properly applies the '--worktree' option to the > configure/unconfigure operations it performs. Thanks! This version is really clear. > diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh > index 6e19ebc922a..b3864e22e9a 100644 > --- a/t/test-lib-functions.sh > +++ b/t/test-lib-functions.sh > @@ -542,8 +542,17 @@ test_config () { > config_dir=$1 > shift > fi > - test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} '$1'" && > - git ${config_dir:+-C "$config_dir"} config "$@" > + > + # If --worktree is provided, use it to configure/unconfigure > + is_worktree= > + if test "$1" = --worktree > + then > + is_worktree=1 > + shift > + fi > + > + test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} ${is_worktree:+--worktree} '$1'" && > + git ${config_dir:+-C "$config_dir"} config ${is_worktree:+--worktree} "$@" > } > > test_config_global () { The test_config() change looks good to me. In the future, I think we should extend this so that we can get rid of test_config_global() (which is basically the same thing) and have only have one way of doing this.