From patchwork Mon Jul 12 22:31:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randall Becker X-Patchwork-Id: 12372481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62854C07E99 for ; Mon, 12 Jul 2021 22:32:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ACDD60240 for ; Mon, 12 Jul 2021 22:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbhGLWew (ORCPT ); Mon, 12 Jul 2021 18:34:52 -0400 Received: from mail-co1nam11on2102.outbound.protection.outlook.com ([40.107.220.102]:11552 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229931AbhGLWev (ORCPT ); Mon, 12 Jul 2021 18:34:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b1ue+CEVq9JMSr20x8i+tqk6gGJ77KSn/E92b30HuMPJXq8/QRXA7DVCm75tpP26PQ+w1UPkOVY/EHvYBfxAwG8176AhqgnX6oh9X3KhzUKyefzRJDk9R0TPjr7Xu7XTKc6O39sp3VHmvuADwVkxPD1cnIH48fNTKN9an6cZS/n8uGwplU4+pSztRany3fA5eV+dwOZBT/NHJ5f6IXpWieR8HXozRKD6p7DqXQvUhJQOmHqJxqmRymkjmUf9FXBiwQQBOGhoqQGQboA4FdlWrHZzkJblsaMOIlYtfoZ6yeSBUGuQgd+uUMcEHmmj74P5uW7OKoIyy/OHBWQ0LNduDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=afz3X26S/Biv+8aunuCtXbg+ToJy4tuQJsoLQ8W9BAE=; b=YCLwWfgs3/1gnIu5OquukQy4rhxMfTUJEC0/8mu9z+1ssrwPHCDcNK/GfW6jQCldMUpj3P3hCB/2GWkwMeYPnl18UnTEre4Po4e2dtKsZE7eoPvf8TuR3rKiJ4v84klP1bheZ/z8qKfM5oCCMlvGqQ6Qms0Akask6a+tJ6lajOt+NIO043lR5vlLimCYY+N0wrv+fXB68v2y0K7lCPhM1JBTLJUemTTfumUqvt0kFE5ZTpxCZGQTEiLpe/4yNmryDAdUxerRNl6IwD8x9PG/3W/kg4DtbCgjOmcqPs6mPVyg3nbjdjFgwf7h9tbK+r4HVTohf6SDHVwt7lD61IUReA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nexbridge.ca; dmarc=pass action=none header.from=nexbridge.ca; dkim=pass header.d=nexbridge.ca; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexbridge.onmicrosoft.com; s=selector2-nexbridge-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=afz3X26S/Biv+8aunuCtXbg+ToJy4tuQJsoLQ8W9BAE=; b=ugfbw+lviDetvIBJXf2PJONf6Eh7PP0PglwV9l81mIlX6JcSDu24p+3YfK1qrypseVOuIUhxiVFoiNWGmgkP1bR1HQGB7I4GurDUuAuGxSWnsVLM+NNxlRyw5UU44D1ynvhEitdvMOoslltR0gkl/o7Tc3XF9PUriNzcoVM1G7Y= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nexbridge.ca; Received: from DM8PR17MB4934.namprd17.prod.outlook.com (2603:10b6:8:3b::24) by DM8PR17MB4936.namprd17.prod.outlook.com (2603:10b6:8:37::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.27; Mon, 12 Jul 2021 22:31:59 +0000 Received: from DM8PR17MB4934.namprd17.prod.outlook.com ([fe80::7c5c:6e02:71c6:915b]) by DM8PR17MB4934.namprd17.prod.outlook.com ([fe80::7c5c:6e02:71c6:915b%7]) with mapi id 15.20.4287.033; Mon, 12 Jul 2021 22:31:59 +0000 From: randall.becker@nexbridge.ca To: git@vger.kernel.org Cc: "Randall S. Becker" Subject: [Patch 1/3] config.c: add conditional include based on worktree. Date: Mon, 12 Jul 2021 18:31:37 -0400 Message-Id: <20210712223139.24409-2-randall.becker@nexbridge.ca> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712223139.24409-1-randall.becker@nexbridge.ca> References: <20210712223139.24409-1-randall.becker@nexbridge.ca> X-ClientProxiedBy: CY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:930:8::38) To DM8PR17MB4934.namprd17.prod.outlook.com (2603:10b6:8:3b::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (173.33.197.34) by CY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:930:8::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 22:31:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 332b512f-2940-4c8b-b8b0-08d94584dd17 X-MS-TrafficTypeDiagnostic: DM8PR17MB4936: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MkFIFZEi6l1oBXZtlOkmm2pS5n3sJDCVHvMSqqanSB0f0oUgNDhcdKuTrFVCMY3IQjuQXvSTxJD+yzEYjlkiwAcAr9EMPpzjpixPJ+CTUoMsirKVXG3mPh/NibdZraIT3BqGqgB9a2TE8F7fBcZfVKxxKkLW5w9PXB4QEiMGJiEPYPHgibAB8pdDmwHn4hQL6k+Idt8jP2rsYbq+sr5+xl1HG3zzvwvaP6lUE2fjRWuGk4IVGxaZ+DjtZi/d1ah96ZgosZAaRjXLlkfPOwDm8j5ipfKu+52UlSuxpcfPziIxnNOFgvilIvN/dj0386GbOr+tiFSQ1ONF3IijZUn4N4jZxiX8zwJDlKwVCdJ8oZqQ/VdVckh/OMztlM8XebztlrrDf+rOJpmBdKCcb3rJXSpglUjQrJKPAc2PV4NBE1s/OMu6Bdnx63vljSVb063kjjLaX1zNUggSSytG+CCrRInSfM1peEK2BUfAEgyfTcSHykJGRp0o2CGZ1nPbuCWnZDmpB4vYTAZmiHEbay+/qWEm+RVJhwHuXtb38fY6Abp+nzwUbCeQ/pAFNID4fwQZey3HP8AyG7g/5mBpWZgex9dGMFJGfnfzE81zh51FzRhnw+nPaivc7i9oshzRyQhdYmw2xFWvq2XsS+iTVIj3vNrcnHMoe5jRoRXUoA7j9/EULVp5kgIo7QxXv++K7PqKlCushjheq8n3qFWYiJ2Nfw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR17MB4934.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(136003)(376002)(396003)(366004)(39830400003)(9686003)(66946007)(2906002)(83380400001)(2616005)(86362001)(36756003)(186003)(5660300002)(52116002)(316002)(956004)(8676002)(38100700002)(6512007)(38350700002)(8936002)(6506007)(66556008)(6916009)(1076003)(4326008)(478600001)(26005)(6666004)(66476007)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CiQHdQhZzAPubtRhDFXqGILUnJerfYCnVN5rpEqUTXtEXLtn7SvLiG5xi05pBnqp/OZNLDypq6xL1gIc8CcxYWb4REla6f3lh7OG2hbXUp8Xy6dRSTFP7vLxnaDIK8cIctuZZhQgbjMwks68AS3HQ+x+Udn86OdrJKSjEarih7tdRwVnLC/oL0inXoB/WAnKj8paqBB2xV+GSF5yx17+j9ls7BR6yu1uNv20qBUoKw5GhGWtq+IFWqZxfM8ded8GHGOGmbNshK7agX4YWoUwnXVwLbwJ3S8J5DV6HB2yb4Jggc5E7//mQRVo69n4IqOw69ssbYk0xCS/ihPg2wWE8lBfrH0ZPF5KEmPRJXy6sO6wXw2JX8tqvES66v7tEhxY504i6EwMZrRnS7EE5HWC4siwPgQF/+E5aEK8ygyB8iD1KmMse/d6INXFs8g3F/uYwu18kQC784E9sBzyT0UWXP/2OY5QaLFe7I+YUXlcyVhTfwlnDizeJV6NOdM1lS/Zvgi8S2fNLa1zhpZpqUZl89GFp0KKinxEAdUYzKT4Itr7optuDpTdqCNRbfsE4nSTMMG4cPhRD6TtKZZGhils5Gp2QV+ey/mJv2WrHkOMNCgBrmuAPmymyH//3BTSgWcimZYZmLrl8VCeLy5nOq9Yeb/XjDmHiKPbB7uAVV1oYfe8B+305umge1JFExZ4evha29/ArKlrXpE8PQVZ1IPrO1AIaYCENZ/TcMU/QE7O5lFifYHgDLuDtH/HdZwIaXuV6y40Nf+Bu+h8PWOCAMuEzbjK2rfY1hzkcrgoBFrthkPSss4SoP6AiuyVRUz+TeOzv1b52SsNAjacodqoOwdWpcBYD24PTEM0gu3cgAZ7OH+mbhNLTMY6XapZ44+66Y50fpjamcmQUWTW2RW6xF1nJoAZdrTXN1xiL+ZgOa31PzLiNckTXWcSstQndwQhdal2CghA92VWfpBqiccPPtckHlTKhXdksKmfMFpdqp52xmmAGK2g4D15EngCWyFIFK5zJzSp/YU+HvlAG5zZra41Xfc0vUPHf/d8DYIPsd2pY8mo1NiAmuOYCdCzH/350gJ7RzmSvyBwCcT+5uT0AgIoB6IX1EZnod4VHqVPTZi3C+x9NaF1yX+7b8J7x5VfFJhyiiQeCW698SDsPCqw29vV42PFr+gf8+7eKljC0nb+DHYs31vLj4beFUjWdjyr9Gk5nseOXIfngqt6tFKML6gQ0zvZPx3RDi4/je27KQBnk5/asneAas63mle2BNJFdNKvKzyDDW/Ut9+SfUAAOsPOet4pBZziDLKxRGAD7KTOXb9AVMuX/Shkwvcvbic+MEmH X-OriginatorOrg: nexbridge.ca X-MS-Exchange-CrossTenant-Network-Message-Id: 332b512f-2940-4c8b-b8b0-08d94584dd17 X-MS-Exchange-CrossTenant-AuthSource: DM8PR17MB4934.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 22:31:59.8707 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d6eda728-7424-4770-8f6a-462632ca4c1d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gOucd4cpAVAhU3AEn0cBAnF3+yzkQUaETz9kRUeBTCa+HRuS63LSnEjOL9TERkOueini/TpZKiUvLzTEFppPQ57UDngtuz6w3Ft1HEBF3gU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR17MB4936 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: "Randall S. Becker" This enhancement extends the [includeIf] semantics to include conditional inclusion based on whether the conditional is within a specific worktree or case-insensitive worktree. The [includeIf "worktree:path"] and [includeIf "worktree/i:path"] and analogous to the gitdir: and gitdir/i: conditions, respectively. Signed-off-by: Randall S. Becker --- config.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/config.c b/config.c index f9c400ad30..e2b2364579 100644 --- a/config.c +++ b/config.c @@ -272,6 +272,64 @@ static int include_by_gitdir(const struct config_options *opts, return ret; } +static int include_by_worktree(const struct config_options *opts, + const char *cond, size_t cond_len, int icase) +{ + struct strbuf text = STRBUF_INIT; + struct strbuf pattern = STRBUF_INIT; + int ret = 0, prefix; + const char *worktree; + int already_tried_absolute = 0; + + if (the_repository->worktree) + worktree = the_repository->worktree; + else + goto done; + + strbuf_realpath(&text, worktree, 1); + strbuf_add(&pattern, cond, cond_len); + prefix = prepare_include_condition_pattern(&pattern); + +again: + if (prefix < 0) + goto done; + + if (prefix > 0) { + /* + * perform literal matching on the prefix part so that + * any wildcard character in it can't create side effects. + */ + if (text.len < prefix) + goto done; + if (!icase && strncmp(pattern.buf, text.buf, prefix)) + goto done; + if (icase && strncasecmp(pattern.buf, text.buf, prefix)) + goto done; + } + + ret = !wildmatch(pattern.buf + prefix, text.buf + prefix, + WM_PATHNAME | (icase ? WM_CASEFOLD : 0)); + + if (!ret && !already_tried_absolute) { + /* + * We've tried e.g. matching worktree:~/work, but if + * ~/work is a symlink to /mnt/storage/work + * strbuf_realpath() will expand it, so the rule won't + * match. Let's match against a + * strbuf_add_absolute_path() version of the path, + * which'll do the right thing + */ + strbuf_reset(&text); + strbuf_add_absolute_path(&text, worktree); + already_tried_absolute = 1; + goto again; + } +done: + strbuf_release(&pattern); + strbuf_release(&text); + return ret; +} + static int include_by_branch(const char *cond, size_t cond_len) { int flags; @@ -300,6 +358,11 @@ static int include_condition_is_true(const struct config_options *opts, return include_by_gitdir(opts, cond, cond_len, 0); else if (skip_prefix_mem(cond, cond_len, "gitdir/i:", &cond, &cond_len)) return include_by_gitdir(opts, cond, cond_len, 1); + else if (skip_prefix_mem(cond, cond_len, "worktree:", &cond, &cond_len)) + return include_by_worktree(opts, cond, cond_len, 0); + else if (skip_prefix_mem(cond, cond_len, "worktree/i:", &cond, + &cond_len)) + return include_by_worktree(opts, cond, cond_len, 1); else if (skip_prefix_mem(cond, cond_len, "onbranch:", &cond, &cond_len)) return include_by_branch(cond, cond_len); From patchwork Mon Jul 12 22:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randall Becker X-Patchwork-Id: 12372483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498E8C07E9C for ; Mon, 12 Jul 2021 22:32:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BFFF6120A for ; Mon, 12 Jul 2021 22:32:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232131AbhGLWex (ORCPT ); Mon, 12 Jul 2021 18:34:53 -0400 Received: from mail-co1nam11on2102.outbound.protection.outlook.com ([40.107.220.102]:11552 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230456AbhGLWev (ORCPT ); Mon, 12 Jul 2021 18:34:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nQBWcf/lAtbnkXCuqCnX9YNj/qgeA5YW5MoepPLqyT0kibsDJpaMynQ/aFFTyHepKm2z7cU4YZQpyf3AwCIxDZ5XOaSQ91JwbiaX3pyXys6s6UoYsRsRteWzPfFUYZ6ajQPIcK5TemhAMLXJ2VnW76Z4D5CmigrQOD3wtTxDq8VbIBqtZlGD2N4HuZQJCBsnGKbnAOWHbV5kwEoiUsKGrofJVpvnupOQOmNkuGhCVN8D9XoP7jGAnQD7UrHz5Ki5AydvjSwbKzi7w1XzQUlgikQ21tAZC1ZTLtUriPiuEAQkrmkj8+3FV1SJ3tnhQ8rqCWy0wXEGk8i90OzkfeSQgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nXiyiHjSSsTvSzs3EhlH5+qL3UID/RMbMThW0BmePPE=; b=jfqFfAc9giOYiCP9avEZ31ILA0NBE/EWviskO7ChmWgK6wQn6CiQTl4ix8U4kvXL17dmY0mMd44bALLNmrxfNIuem39zlvRvO0fM5UubK7zrZrUrxpW53VcEBzRN/H7BnCNCnn12Q207RatYanj9/y4d7FFsBt+dBssEo6g2qRgQmd/lqpU/akCP91Pg5X7FrbmtYopjUxmgK4TF89+yDWKF6ULcd1t3PeEIBZx64lsNuVX6+kZ0eI9iUBciyRYtJ+RcGWv4JA4l4PUSdVvE7gUfZZVJ7gwWrI4XCtQ877zcF2zLCRQLPLpYvtz+OuwkWdb21et+pvXKuZdXVFYIIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nexbridge.ca; dmarc=pass action=none header.from=nexbridge.ca; dkim=pass header.d=nexbridge.ca; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexbridge.onmicrosoft.com; s=selector2-nexbridge-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nXiyiHjSSsTvSzs3EhlH5+qL3UID/RMbMThW0BmePPE=; b=r2u28HlDJ8MLYk+Fbt9LvgMkLpCADjkdt7Ok67vdWqSRZAYOf/K+euW+FNsbhZUZfZlb8eBJ7zNg87qldM8qx+EhWlBlck+URDIEBWyr/0tbybQ82L5frBMyZLDACfjc6jb1wBbUH/xkdHXH0O1ZiOu+0QmUCFN4BhdVAC0tcTg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nexbridge.ca; Received: from DM8PR17MB4934.namprd17.prod.outlook.com (2603:10b6:8:3b::24) by DM8PR17MB4936.namprd17.prod.outlook.com (2603:10b6:8:37::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.27; Mon, 12 Jul 2021 22:32:00 +0000 Received: from DM8PR17MB4934.namprd17.prod.outlook.com ([fe80::7c5c:6e02:71c6:915b]) by DM8PR17MB4934.namprd17.prod.outlook.com ([fe80::7c5c:6e02:71c6:915b%7]) with mapi id 15.20.4287.033; Mon, 12 Jul 2021 22:32:00 +0000 From: randall.becker@nexbridge.ca To: git@vger.kernel.org Cc: "Randall S. Becker" Subject: [Patch 2/3] Documentation/config.txt: add worktree includeIf conditionals. Date: Mon, 12 Jul 2021 18:31:38 -0400 Message-Id: <20210712223139.24409-3-randall.becker@nexbridge.ca> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712223139.24409-1-randall.becker@nexbridge.ca> References: <20210712223139.24409-1-randall.becker@nexbridge.ca> X-ClientProxiedBy: CY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:930:8::38) To DM8PR17MB4934.namprd17.prod.outlook.com (2603:10b6:8:3b::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (173.33.197.34) by CY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:930:8::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 22:32:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc2824e2-be31-4ab7-f34d-08d94584dd78 X-MS-TrafficTypeDiagnostic: DM8PR17MB4936: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hRFSCkWlTKrcTVD2qaFqZT8ke5ZLOO/rjy7yvvcktic5+pbxPhB6ZgPWAdRjcwOfV3q0RPWYLJJ6EOHislXGrd3I2IufQBKnFtNP8BTh8ayqAq3CVXCQo9HITNk/5qm38QtEBQN1UTIKcBApoNIKcFWmZ/Z6pityftKObUM7IQSJJnrf+thHBxJOXMFTAY30dLN3ijR+mxXJnJSZNC+aP+DN8xFVYugXpY0xtUp/U9VBE9J/K0ZVmtCY9+QiJj5/VdnIcwnuqoNS5BUKJZG1hQy/1SBoJm/ZvRnLxwc/6SuSzKx9jLcvRnMcGo73N2XtO10SuTzX5AtEEWteEDP1jCo9VjyElmNOutz/M7EZbF+i17Z0Ps3v6rm5AdhGhdqvoMtKyDm/+SlhFTlzvy9A/kBhEp1uLDz5kBIxBnYawFSTy+Zd6gJ45FX0jCKMKIUopDBEjCpwhw8jFV+79Pzz+s//+kDMknzGmZTkV6OBnlae7HaQFkVt+sWzEQ1JUxHpwFI9dakiBZb2Z8zWngzkWhn8iSgK/Coz9wBOtVe0zj7SjdrgKRdMy77eePsZQ90WOI+u7BRVPrXmnwEwYXf6Er9znNKee47i1IYIP0oT5dQA/W7e1IEnGIHLVNyMZzJgMt2dLjCEsywGqTmWchBR/45mJi1Sz0ZHCOHbQ5WzQMZNhlCzFtGMKhVQfRMs6bbh2296rE0vhf8ntyQ9N9ssOg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR17MB4934.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(136003)(376002)(396003)(366004)(39830400003)(9686003)(66946007)(2906002)(83380400001)(2616005)(86362001)(36756003)(186003)(5660300002)(52116002)(316002)(956004)(8676002)(38100700002)(6512007)(38350700002)(8936002)(6506007)(66556008)(6916009)(1076003)(4326008)(478600001)(26005)(6666004)(66476007)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XdRvc5cifywG+v55Oj37sDmhgOQOlbrEqRHo5lsqzf6/O7VRN6IJNA+pDh+pX4H8S1lcd2W/AP5msKTiDPKvz2HHXilg1wtyXyrFPNawl9RJhvzFUBmUGkuej0vfOHYKaywn7xc0/QPpERopRcNdLQhB5kKBkitvDrQbT1eDjJlAveQyZsLjQ+hAzSvyp0rVX1RWCoS2Yx2DpH2tl87v9/NprqBezD78LZFgaHR8pZj5B40E5Zx0kkqIhCipmWlOBT2XKVmSWMXHI9Z7caP9QjTeYPFamvyTlCOk5UhOhM3Cj2OngyOwMzvOC3jcMGW+8U4/zxVUGdDA+heZU0i7ap+NKTr6BPRsHtNes1UsDrr5RkpnWn1pAe9JIQXy/cyqx7CSlJMUyju//dh5j6DkZv0rEINlMfUKafOV4F83dpMCej0nInu648VbgmCwPszkNgmrNEm/nW2p/mwGoBZGft/mIUFa5gGcJ+LmtqyFROnvsKgfwsKe69zBbmxhGbgWR8MJafrdbpvJJghH6xTxDBEZ7LZ698LOAb/IjpgUpV9pJvde8vEPePgtYdE/Xjue6f/G4ijZqTU5vkuSAoyoVYzWd9yHIvNAVuCT0zG+2lZSuIvDNgqE6EekOuIBm+Xs+xMBCbuko+8UxWaUFdimgmQT2f9b9+ToHYATWBk0bx69Vw0/vdf6+rIel/o9ox3BehgkaP7Q0a4h2ZOUY9smVhqWQfX2ArWARm5DSyo3IPAE8HaAD2EAGez34CDYaPwzIFmVpwQtpvEwNSS5tVkx1VojCrvERYh0oVAYU8qqrW9TPqrU6twLdIbL9h4QkyuyTPmqbFPflmG/IrCuGQ0xh0hLGY09EpFMADmSVfwjnS0Szy7d+KpUDK8qKF53bQfbnPXy8l/NV9cUIldQjT+eKN1ySEbTzpwcfJFMaQl6pXeG/zrkCgKQ4NQTrXDWqzW1S7dVaxjw/lnsYVFE2uLfn718DMwkJrQMfNPn9RT4PLHlVcAXHM4649mGx0au6N9Q0i/hsis9sELghh8C/gfKCsqbsWQI0JooUuA/uK9F65f9+UR1KsNZgqNq+EMSE1xNBugkLUvUXhmP2ekYNdWQfsANs+LepbLjrW5JRN4p6sJ84cuNWsbhc6s43TjYRKyapcCFNWvduAvVpWUIXa+N052uj7Xp3+54M69d+kHskSTRqqhPoipJ9Yz3zUNeJoAuzo1xh7RAZpz/zk54mE87mYUelkp8iGxRlKJ1TdKkRf1s6zJ72Z/OzjrNR+DnPdKfmndGfH/WelYp5xVOieeJAIal1p/uRcUHOTa+T3Q1Vpsb6wdxOjZ2CgPj2E/Z7cCC X-OriginatorOrg: nexbridge.ca X-MS-Exchange-CrossTenant-Network-Message-Id: bc2824e2-be31-4ab7-f34d-08d94584dd78 X-MS-Exchange-CrossTenant-AuthSource: DM8PR17MB4934.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 22:32:00.5467 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d6eda728-7424-4770-8f6a-462632ca4c1d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QSutTgztDo5dwF1drYOYau9s/yKMNTl1Zf67ZKVDUNVNu0tPlQy0mxJqybaxbrKY2Nsax/Xp3vflbSSBgvO//CwIgnHt4xGRKB1iGJeXbjs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR17MB4936 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: "Randall S. Becker" Documentation of the worktree and worktree/i conditionals is add based on gitdir rules except that the trailing / form of the path is not supported. Signed-off-by: Randall S. Becker --- Documentation/config.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index bf82766a6a..7e951937ae 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -143,7 +143,16 @@ refer to linkgit:gitignore[5] for details. For convenience: `gitdir/i`:: This is the same as `gitdir` except that matching is done - case-insensitively (e.g. on case-insensitive file systems) + case-insensitively (e.g. on case-insensitive file systems). + +`worktree`:: + This is similar to `gitdir` except that matching is done with + the path of a worktree instead of the main repository. Unlike + `gitdir`, the trailing / form of the worktree path is not supported. + +`worktree/i`:: + This is the same as `worktree` except that matching is done + case-insensitively (e.g. on case-insensitive file systems). `onbranch`:: The data that follows the keyword `onbranch:` is taken to be a From patchwork Mon Jul 12 22:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Randall Becker X-Patchwork-Id: 12372485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FCA7C11F66 for ; Mon, 12 Jul 2021 22:32:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5720161245 for ; Mon, 12 Jul 2021 22:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231948AbhGLWey (ORCPT ); Mon, 12 Jul 2021 18:34:54 -0400 Received: from mail-co1nam11on2102.outbound.protection.outlook.com ([40.107.220.102]:11552 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231904AbhGLWew (ORCPT ); Mon, 12 Jul 2021 18:34:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l66D+UHOdezxQkQ5QEQ593ZhvA9VPKuLMZi5t/z97c7A+CC7aRUmj/GaJau6f9/3wZQgJDKQnvQvtZLNr5zjWnC5x2GIFEp4ifCXzxp2iSA2IK+7ZulBrBg4SdQCPEKnfJmBpkslBUpzziqq44NlD9/iy46UFUlnqqwdyJEI4rOKMFeZ/QFNuw1bDBX1QDJhme0cKLVHUDGs4KjdbV1+e5fV/b8sIz16HC4YKoZTXbjFclGQVRJfpOg32FmhsOdCtRIna//SGs6wUNfjK+QHjh2q1UGUt0kuNh/Odjt6HeNzqEt8+IfPIKmGsSbzTCFs06MvfdhrAabYUrik6Njmcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8mVHlO5529JNiymc9Y8GaBnH4H7nAMjhf5qnxYcWyM=; b=cFcNupt9iJ6WbY+W62yMaIaOAdfmLbhdygL9s407KL6J52W9Nd4Fx7Z7aWIM0H3QU/PpS4m9XA+9IDNxxnxDHWR1GZrXTns233axQcc3vvYGvc+ushxovW2nCucSEsYhsJSDQ6oQ0mMVctyRQGg7IjZUPsLtfpCYENIVPt+8foOKtDIEkVpHJPSzyfqHS+H0Fy1ETAjl1XY+CAIE/wT7pq0inBDv0qPv5iVF7CZqTB+FVzBLeWMFeKu4eA2SyEFvXSiTnXr71sqvR7PxJoEcC07MErK88DUnMTQGT1ZHHnIrSUmbgr/qSqhZ/kZMENSnrtbZewXjpfInpveUq5hejg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nexbridge.ca; dmarc=pass action=none header.from=nexbridge.ca; dkim=pass header.d=nexbridge.ca; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexbridge.onmicrosoft.com; s=selector2-nexbridge-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8mVHlO5529JNiymc9Y8GaBnH4H7nAMjhf5qnxYcWyM=; b=SQvfeUnsuWL+1U02j8BRyt/R/XQROSfyWsVISvlZR/ttY0KzZH5M5XMMIf8NpFieoCziy7ATZVungarbw/KPAXqW/hxdfXzx6SxXCCPS8x6LfbOEW88W03R2JX1z5aSidOZmi2XQ279xtpOnHs2G7J2QjfyzPo0oqdkwVec9H6U= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nexbridge.ca; Received: from DM8PR17MB4934.namprd17.prod.outlook.com (2603:10b6:8:3b::24) by DM8PR17MB4936.namprd17.prod.outlook.com (2603:10b6:8:37::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.27; Mon, 12 Jul 2021 22:32:01 +0000 Received: from DM8PR17MB4934.namprd17.prod.outlook.com ([fe80::7c5c:6e02:71c6:915b]) by DM8PR17MB4934.namprd17.prod.outlook.com ([fe80::7c5c:6e02:71c6:915b%7]) with mapi id 15.20.4287.033; Mon, 12 Jul 2021 22:32:01 +0000 From: randall.becker@nexbridge.ca To: git@vger.kernel.org Cc: "Randall S. Becker" Subject: [Patch 3/3] t1305: add tests for includeIf:worktree. Date: Mon, 12 Jul 2021 18:31:39 -0400 Message-Id: <20210712223139.24409-4-randall.becker@nexbridge.ca> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712223139.24409-1-randall.becker@nexbridge.ca> References: <20210712223139.24409-1-randall.becker@nexbridge.ca> X-ClientProxiedBy: CY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:930:8::38) To DM8PR17MB4934.namprd17.prod.outlook.com (2603:10b6:8:3b::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (173.33.197.34) by CY5PR03CA0023.namprd03.prod.outlook.com (2603:10b6:930:8::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Mon, 12 Jul 2021 22:32:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54722264-e7a6-4c29-fd9e-08d94584dde2 X-MS-TrafficTypeDiagnostic: DM8PR17MB4936: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IRYyP8V2+W2j7NagjwDy0X8WkXvA3EpEBMn8mITsSa2J9/38pVacQDHIVFh5gJpxjCwVJvxyhm+coSG6Bim4oWVlk1qkfwaLnwqaCOcjimWSpFIem5W1kxp6vm/+eIW0QdN40HsBeYxXG70g0C/UQ8FyszaYMBZdwpecb5R5pD1x+W5OC/5Tal556VrnI9NdWUJTZ+WaFCDgcJkcSh1GhaUYC+NVxs8xYOeXQpWwIpoY/n3v8+3D76wokCtqcklQlwOFxWUs3JXlJgMA1BOTaTGFCAcJDLdgPB7v/V0fMRzvwyxe+TDXL3v4oeAo3Dq+FV7C7S8EXLdfGNFMl7Wih3zPAB3dKtGG7WYQHiLKQaOCVR88s3tahAZrT4oCQeelUWzbg4kAhteNW4C8335MThOO/j163gr7HogBEM3U5l/1Mu4FddvXaeVQy1gsWHjFLvsGLI6/mcgnlcpdXGdj6Px8B7A3iVve4gjvcfmTUIjMfBTOZEUQXC7DxrvvqUvbmYUkc5h9++PuqcsOxySVOBsCVftvRjncyEKezH0wwkyn2uhkPSydkP4gj3evQiKQNiLnno5na9i/CT8Dwy222myk7zdaY4bzJ2cC6GtM4y90GvqILZ8SLgPR+4XlkUj/N9wlMnhY8S5nmVFepdchsrqiosQd0dgLD8dhoTEN63wCDmCmKYw+3rFnCMfxST3+GhYSZ43ARqXs9IU/KtQDAQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR17MB4934.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(136003)(376002)(396003)(366004)(39830400003)(9686003)(66946007)(2906002)(83380400001)(2616005)(86362001)(36756003)(186003)(5660300002)(52116002)(316002)(956004)(8676002)(38100700002)(6512007)(38350700002)(8936002)(6506007)(66556008)(6916009)(1076003)(4326008)(478600001)(26005)(6666004)(66476007)(6486002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EDn/OlN6WR4OM4WdSLRbQkb5RNTgNTjuTW2Z/3TBxl5j3DDa0bevDF00nIpnwINbwZvy7YuBqSCfddjGlmMFOuoqkMQmsAxakMW2UtCuD8WrO+ofTzX1ZsajJMqjhhI/jfzh13NpEX5vhXdSnLqxpdiESeXe5zmlosxCmNKXfIt9M9rofc6RU04fK+E7ffcseOq2be6tdO0fO0YQTGiCDManX8rmCRGp/b7b7G6cnd5s3V3RvygcwlTU5i3DtIbbxcgeuPEvLVFz08PxvlVg2WX2OY9sYkPrlctN0EevDqW3Tm39VR2xPK7bKlIAhvU+mKGInor6KApz4XFiyRqJcZCKx3lW+PCL49RgwT7NtFzz3lXpi1wtWRaRfWKyn5+NF2Oc6tg6b296QGjww3yV+ufMzk/A9mFqBy3PXTQwCjLoJ31j4tMFgH23pE7AthlqQ+++woRYK0jD7clN9G7tf1dDnzM1XM8l/H7lyU/rtF3dMbnXVuRFLNhyU8g4zGesBlgtwGOcGq9njtAtUPtU41qPKlr8/AbrWZNQ3rqNUs6XumtVT9cZ2bLFEsxEMna1nvHJpa+4dHr8FZzW9tV0SeKia/f+VW7yN52FN3Iba+RW23e9K3koWOoMgsX2AFfZStjgNNVUnx9noaOvUXCjz3ZQ2I0OgolGA8EJXyDjC0i+w8Cxq0y/vyfHkhq/N2b5q1DLnUCHfVSpvmlwQVDpNWcUcMhLtIaoRAXdit/rnWXruyWjYf5Woqlfad6r7E87kZSAyQ1rkldxZ6N5ZHLVtZqvixPiR1/CsvHlO95OnTdHMH75IGacga8+tNdz6m1BCbvZtG8rgdgRzEJQqTxwzMQgonALZEg2xLc8Tj0ayc3botXs3EUcG89utEZdpKVC4vKmdGdTxmQo6pSnpphSLg9hNg02Pldj3TttaSmbngb2X9RS0PKC35Q6Kajx3ob7JxeoWPqrWO8IGfayF8b9gENiBY9+pI/aVb308K6ByxIhEyQDA1JHaxrivklGl2KTb9nbsCk2pyXwJJmSBxxkMBHumvT+hB6cEZdFGVvEIxf0vUxzHF8hGaWXDktVOPBCPRf+vO74Ozm7Xt9rMaqWWyIfIVcfj7KbxOeu0wi6dAPdLB83yYA0L+x3wXVKNvCL/wA8L7pMUJBwgGgrrZAHBLuGFHp9N1dh7N48DsGnL7YDbapuw78oKIjQhxNGPtT/lYUIgMzsOj38+BNPkmGY5VIp0INBGhy2vvw0ztOFIv+wiYluBFwjWkml94MXsG71sYBG/5dcoTc/FRf3iBNxsEta17t3qPlV9Ei5DHrpCpCqAlwdhy/a7q7Rp3rqdCny X-OriginatorOrg: nexbridge.ca X-MS-Exchange-CrossTenant-Network-Message-Id: 54722264-e7a6-4c29-fd9e-08d94584dde2 X-MS-Exchange-CrossTenant-AuthSource: DM8PR17MB4934.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2021 22:32:01.2297 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d6eda728-7424-4770-8f6a-462632ca4c1d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZAfJCmXGz+l/NEZdgmSpu9QawmKRqvjOAQ3mxXGvHp+IuMdUNoe5wRTR6J6hzIN8We8i4Y76YkCpGToGxwVSMFzuWT/1xkhMX4AG6cFxS70= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR17MB4936 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: "Randall S. Becker" The tests are a subset of those for gitdir:, taking into account that the worktree: form does not support the trailing / at this time in pattern matches. Some resets of the .git/config file are done to restrict the set of includeIf paths being evaluated that conflict with prior subtests. Signed-off-by: Randall S. Becker --- t/t1305-config-include.sh | 81 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index ccbb116c01..fe1ad106c3 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -309,6 +309,69 @@ test_expect_success SYMLINKS 'conditional include, gitdir matching symlink, icas ) ' +test_expect_success 'conditional worktree include, unanchored' ' + ( + cd foo && + # Must add a commit for worktree add + git commit --allow-empty --allow-empty-message && + sed -i "/includeIf/,\$d" .git/config && + git worktree add ../foo.wt && + echo "[includeIf \"worktree:foo.wt\"]path=bar" >>.git/config && + echo "[test]one=1" >.git/bar && + cd ../foo.wt && + echo 1 >expect && + git config test.one >actual && + test_cmp expect actual + ) +' + +test_expect_success 'conditional worktree include, $HOME expansion' ' + ( + cd foo && + echo "[includeIf \"worktree:~/foo.wt\"]path=bar2" >>.git/config && + echo "[test]two=2" >.git/bar2 && + cd ../foo.wt && + echo 2 >expect && + git config test.two >actual && + test_cmp expect actual + ) +' + +test_expect_success 'conditional worktree include, full pattern' ' + ( + cd foo && + echo "[includeIf \"worktree:**/foo.wt\"]path=bar3" >>.git/config && + echo "[test]three=3" >.git/bar3 && + cd ../foo.wt && + echo 3 >expect && + git config test.three >actual && + test_cmp expect actual + ) +' + +test_expect_success 'conditional worktree include, relative path' ' + echo "[includeIf \"worktree:./foo.wt\"]path=bar4" >>.gitconfig && + echo "[test]four=4" >bar4 && + ( + cd foo.wt && + echo 4 >expect && + git config test.four >actual && + test_cmp expect actual + ) +' + +test_expect_success 'conditional worktree include, both unanchored, icase' ' + ( + cd foo && + echo "[includeIf \"worktree/i:FOO.WT\"]path=bar5" >>.git/config && + echo "[test]five=5" >.git/bar5 && + cd ../foo.wt && + echo 5 >expect && + git config test.five >actual && + test_cmp expect actual + ) +' + test_expect_success 'conditional include, onbranch' ' echo "[includeIf \"onbranch:foo-branch\"]path=bar9" >>.git/config && echo "[test]nine=9" >.git/bar9 && @@ -348,6 +411,24 @@ test_expect_success 'conditional include, onbranch, implicit /** for /' ' test_cmp expect actual ' +test_expect_success 'conditional worktree include, onbranch' ' + ( + cd foo && + sed -i "/includeIf/,\$d" .git/config && + echo "[includeIf \"onbranch:foo.wt2\"]path=bar12" >>.git/config && + echo "[test]twelve=12" >.git/bar12 + ) && + ( + cd foo.wt && + git checkout -b main && + test_must_fail git config test.twelve && + git checkout -b foo.wt2 && + echo 12 >expect && + git config test.twelve >actual && + test_cmp expect actual + ) +' + test_expect_success 'include cycles are detected' ' git init --bare cycle && git -C cycle config include.path cycle &&