From patchwork Wed Jan 16 10:31:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECB696C2 for ; Wed, 16 Jan 2019 10:32:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4462CF6F for ; Wed, 16 Jan 2019 10:32:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5522CF94; Wed, 16 Jan 2019 10:32:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47B5B2CF6F for ; Wed, 16 Jan 2019 10:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404109AbfAPKcO (ORCPT ); Wed, 16 Jan 2019 05:32:14 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44269 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcN (ORCPT ); Wed, 16 Jan 2019 05:32:13 -0500 Received: by mail-pg1-f195.google.com with SMTP id t13so2644016pgr.11 for ; Wed, 16 Jan 2019 02:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SmN7GHeCWf5QdQx61eymU4pBBvsEd0XAQQjG08lothA=; b=L/i3Uwrf77v4WcwZDsDLff9uRebqD49pRW48OGVdd+kdXJyXirrfOD37OWXfG0Eg5J fBiJKJ3f+nWjsHJMvToeFQ5oA4LXObTZ2CAVE7gtsiv8hVxry3GabQV0OWR9TUdhZg+2 CqsPol76IGBg4HQT99VXSuCbylHscgZICJ99UWqvBJ2VaVgqm1eSWafl4ko5xbk30Ou5 ePHzoL9her5ZCKCgaahNpdzFMdzu5UGQY00GSnRu0va6S5mW043yZQaHKgriHetQI+0r p2UScHNoZbdqXTrKyuAtxzBZ1hb5hakatNJHghtCOxsgD+t99Dgzyc9o1gOA/OYwx4wg +jDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SmN7GHeCWf5QdQx61eymU4pBBvsEd0XAQQjG08lothA=; b=EE1ZZc0wd/C1PRrs71OUeUpMMI3IQVNEFPYmo0Pj4q30MANf+klyzTZ4xIwORODv4G JKYMSY2igo58ByGK7QMgGdJ6haO6nhKZfAObwhY8qgfIotB/JILcUSFtPIcC5dGwmYqY vAwp7SPzz7Dm6V+2Op4/jf+UI1gAzmKREv8MDCK1hAHl6/zS2TNcQNYfhysMrhn+m0F0 fYMkHpWAVEcMzYLiyViI9IrC1BMHZc0q12YFBQ0vfQP8FrfasK4OAUDoPPn3s1TMLavB /lvqBr73VirC8gdFKrTWhbJHGLI4FaR5+5BcRkDF34r5fyVAlsM2FVT5TEyLPYUFT2aG IF4g== X-Gm-Message-State: AJcUukdwk1XWOsM71nm1lAd0S/7o0SXr8QChpgMsCVTFmoaftrnERhy2 TwFgy5VYFViBHygk6/qRDeHv5qAh X-Google-Smtp-Source: ALg8bN7hs3A6PPFTDPXIU0a1MZBzzf2OJRljxwXFnZFWvPPfnXvGbJRPrFOcuUGWy21UIb81Icua1w== X-Received: by 2002:a63:8f45:: with SMTP id r5mr8121959pgn.222.1547634731974; Wed, 16 Jan 2019 02:32:11 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id d129sm9580844pfc.31.2019.01.16.02.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:11 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:06 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 01/10] doc: about submodule support with multiple worktrees Date: Wed, 16 Jan 2019 17:31:50 +0700 Message-Id: <20190116103159.9305-2-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This lays out the very first step of making multiple worktrees and submodules work together. The first problem is git-submodule keeps per-worktree config in $GIT_DIR/config, which is shared for all worktrees. This series makes git-submodule use extensions.worktreeConfig and write submodule.* to config.worktree instead. The rest goes on and on about the remaining problems. But let's talk a bit more about solving the first problem. Since it relies on the experimental extensions.worktreeConfig, this support is of course also experimental. On the other hand, submodules have never really worked with multi worktrees before, this change can't bite anybody. Second problem. That is about multiple worktrees at superproject level. At submodule level, we still can't have multiple worktrees because git-submodule writes to submodule's "config" file (again). Fixing this is not particularly hard. Absorbing submodule's git dir takes some work but is feasible. This could be addressed soon in the future. The third problem is a big and complicaed one. Submodule clones (inside the superproject) are per-worktree. So if you have two worktrees, and these have one submodule, you need space for _two_ clones. This is definitely not elegant. The tenative plan is to move clones from $GIT_COMMON_DIR/worktrees/X/modules to $GIT_COMMON_DIR/common/modules. The latter directory is shared across all worktrees. Once we keep the clone in a common place, the submodule's worktree can be created and managed with git-worktree[1]. Another good point about this approach is we could finally safely allow "git worktree remove" to work with submodules. With current solution, removing $GIT_COMMON_DIR/worktrees/X directory means also removing potentially precious clones inside the "modules" subdir. But whether we can do this depends on: - if we need separate ref namespace for submodule on each worktree - how does submodule's worktrees (remember the second problem) interact these worktrees Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/git-worktree.txt | 8 ++++++++ Documentation/gitsubmodules.txt | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index aae8e1d8b2..3510fd5331 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -267,6 +267,14 @@ configuration that you do not want to share to all working trees: - `core.sparseCheckout` is recommended per working tree, unless you are sure you always use sparse checkout for all working trees. + - Most configuration variables under `submodule` group in superproject + should not be shared. ++ +------------ +$ git config --local --move-to --worktree submodule.active +$ git config --local --move-to-regexp --worktree 'submodule\..*\..*' +------------ + DETAILS ------- Each linked working tree has a private sub-directory in the repository's diff --git a/Documentation/gitsubmodules.txt b/Documentation/gitsubmodules.txt index 57999e9f36..d91817b45d 100644 --- a/Documentation/gitsubmodules.txt +++ b/Documentation/gitsubmodules.txt @@ -222,6 +222,23 @@ submodule active pathspec, which specifies that any submodule starting with 'b' except 'baz' are also active, regardless of the presence of the .url field. +MULTIPLE WORKING TREE SUPPORT +----------------------------- +When you have more than one working tree, created by +linkgit:git-worktree[1], submodules will not work on any working tree +until `extensions.worktreeConfig` is enabled. Since this config +affects more than just submodules, please see "CONFIGURATION FILE" +section for more information before turning it on. + +Once on, submodules can be added in any working tree. The submodule +itself though cannot have more than one working tree. + +When submodules are created in a working tree, their git directory is +also per-worktree, e.g. inside +'$GIT_COMMON_DIR/worktrees//modules' and not shared with +other working trees. This means if you have the same submodule on +different working trees, you need disk space for multiple clones. + Workflow for a third party library ---------------------------------- From patchwork Wed Jan 16 10:31:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 683E613BF for ; Wed, 16 Jan 2019 10:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53FCC2CF8C for ; Wed, 16 Jan 2019 10:32:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4564C2CF9C; Wed, 16 Jan 2019 10:32:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F222A2CF8C for ; Wed, 16 Jan 2019 10:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404112AbfAPKcT (ORCPT ); Wed, 16 Jan 2019 05:32:19 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46381 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcS (ORCPT ); Wed, 16 Jan 2019 05:32:18 -0500 Received: by mail-pl1-f196.google.com with SMTP id t13so2815487ply.13 for ; Wed, 16 Jan 2019 02:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=flZuTF3Bu1w35FXuUxUj0OIBbxZcWwkYwS1FPBYivUE=; b=pPvsKxsCuVLRg/bJgijG0QPLS3hGScBpaLUxo0kdTw9PisF93hMT8g7MwA+zvXcDIy +g0zQNFkOYjpesbkYc5yMAYhWg8R9Gw94qybUv18UBhNIqg7c8bMY0a4GJiAYXakkOYl W8/a0dyr/93EPKxfBonALbJQi0O0DILPe+fjrtF526F/RoMyxoT1K3/jWgZVu73dmb7N Ap1lEg7gLcYW8APX3f3umbxyatGaWJvkhNUAJfvNZn14jCIGu0DYC5mV1vQaNLvwIkct yfDbZKgsSNU7FKcQFLF+F3c3r+itmohuY0pZGwoyIeGtJS7v287ON1EDt0SWlVcRfmlE rKgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=flZuTF3Bu1w35FXuUxUj0OIBbxZcWwkYwS1FPBYivUE=; b=GkZluFByNmHP5bWJCB+SFVy9zE+UnSeIvh4an2usA/tzJuWf/GlGaBkYrYmrK1ccxD 1a5jx/bK5HTBwUgnGLof9poa9670DoJBTtbRa8fw9jrOkqScPHGAnzCVbCWsOWb6cvZm KJaVrxSqF2A4Rpj2aVLXhuqfzG222e6iGgKRioGdIunozDSap1Ypr6P+mCDLsYZfzMqT ZQMOORWe4cr4YcOAkkG9inO+fuCMUQzOL3CjesN61V+FJG5/Xtjh0QgFdERJQiL7xmDK 7JGLfi7HfO+jpG05I2bipBWvWltrN5ULGM5quCO/nlSUcvFFL1QBp7QOQB7Pwy0jC8h5 BRRA== X-Gm-Message-State: AJcUukfpkkEauvQQsfbGjk/mfvNO1y+me+5obLbfVS4+AOnU8MIN+28n Snk6UlNPLdvIoryGNg0s8Lr2z12c X-Google-Smtp-Source: ALg8bN4vjdL8+8aedy03zOpp9QSBn1uN+F9FUkb5z37AddqsfvIZ18iJPML+Zb3LRXi2178q5fB10w== X-Received: by 2002:a17:902:64c1:: with SMTP id y1mr9047327pli.64.1547634737734; Wed, 16 Jan 2019 02:32:17 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id k24sm8422967pfj.13.2019.01.16.02.32.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:17 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:12 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 02/10] submodule--helper: add missing \n Date: Wed, 16 Jan 2019 17:31:51 +0700 Message-Id: <20190116103159.9305-3-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index d38113a31a..232bfaac7f 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1297,7 +1297,7 @@ static int add_possible_reference_from_superproject( die(_("submodule '%s' cannot add alternate: %s"), sas->submodule_name, err.buf); case SUBMODULE_ALTERNATE_ERROR_INFO: - fprintf(stderr, _("submodule '%s' cannot add alternate: %s"), + fprintf(stderr, _("submodule '%s' cannot add alternate: %s\n"), sas->submodule_name, err.buf); case SUBMODULE_ALTERNATE_ERROR_IGNORE: ; /* nothing */ From patchwork Wed Jan 16 10:31:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 655A613BF for ; Wed, 16 Jan 2019 10:32:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 508062CF94 for ; Wed, 16 Jan 2019 10:32:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 449842CF6F; Wed, 16 Jan 2019 10:32:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B25F42CF6F for ; Wed, 16 Jan 2019 10:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404121AbfAPKcZ (ORCPT ); Wed, 16 Jan 2019 05:32:25 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42206 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcZ (ORCPT ); Wed, 16 Jan 2019 05:32:25 -0500 Received: by mail-pg1-f193.google.com with SMTP id d72so2649674pga.9 for ; Wed, 16 Jan 2019 02:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/GEeGQp+YLgKeQb9Zfqqzn9tXJ5SYGiJHFn5ZaMRJ7U=; b=aI2U48BPW3C6lJRKZ2/fDW04tTlG9CV7hCk8HzNLQFB4fScfCatbxf6r9bSGD5a0rt jfqSKzn419gfDaWB0aDj6Y+7Ufupe/mqH2JJ11gvuYhn78tk7xV7/+BpmW4jZKDD3uCT mh+uk9pWRifz6TkWm3KmvUcreus1+Zpw/Dp4FXQG0c6LzJ4+wjgQIJsfUcnezzPfN/Qc TwbQRISJOV2fSK2IWX0TxBb/1UQ+WKFQddUT6rH02mdV9izBIBr9OO4+VjuFG+BX0nXW ggkWLiTOBG5Q9voWeRH6q0euRMZ8+FL1yF6KYGyvIOENjHR55C1/Z8a+Sf2QjBxZENZB ndQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/GEeGQp+YLgKeQb9Zfqqzn9tXJ5SYGiJHFn5ZaMRJ7U=; b=AIjuS+hwWYgd5K6GhZfuaL+9aDE6JLl5yq7jVsAtnee1+cjkRZOyQF2HXrgjWbYeJy +CCRPribG//lEIQ4+gGwosjW9ZGFYAziqinsY4w8Wvl4VO8r3FgxWyxsna/HLNte6HEN Xzv5C68+f2ZKmZY0bGZqsu5KJih+1P+6JZnSSJBAfxDFrDypsTWjlvWiynHWDVhX7LVS 2CV/DnpXCKdciK6VshXQaE6QjlqfR1s60ScEAn7IcujAFb4Jc+M6ptP2X6jXzkvoz79/ XpM1S9sCijdcvxrgwCKm4PnGEwLR749u9hzhqCrfZOLpNIQCIIztMg/JwosxOVfGr/2v XWxg== X-Gm-Message-State: AJcUukf1/KVyUSvwxDqnZPWpLn2SrYqKNHHJ3gOYkPz6+mKhkjLIagRj mm4f9uYrZY/BGjry0wDQWC+HfwR3 X-Google-Smtp-Source: ALg8bN4skkhrIWihitvzvz0eQ2l8C0ZQGNQjMGOkNv0ARlHMVhHIeZV5ZffBeO1ibHB760kC5vv/sw== X-Received: by 2002:a62:425b:: with SMTP id p88mr9155624pfa.137.1547634743785; Wed, 16 Jan 2019 02:32:23 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id y84sm16692885pfb.81.2019.01.16.02.32.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:22 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:18 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 03/10] submodule add: support multiple worktrees Date: Wed, 16 Jan 2019 17:31:52 +0700 Message-Id: <20190116103159.9305-4-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The entire submodule section in the superproject will be per-worktree and written to $GIT_DIR/config.worktree. The behavior when you only have one worktree (and not enabled extensions.worktreeConfig) is the same as before, everything is still written in $GIT_DIR/config 'submodule-helper config --check-writable' also checks if it's supported worktree configuration. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 17 +++++++++++++- git-submodule.sh | 8 +++---- t/t2405-worktree-submodules.sh | 42 ++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100755 t/t2405-worktree-submodules.sh diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 232bfaac7f..7b328ec060 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -18,6 +18,7 @@ #include "diffcore.h" #include "diff.h" #include "object-store.h" +#include "worktree.h" #define OPT_QUIET (1 << 0) #define OPT_CACHED (1 << 1) @@ -27,6 +28,18 @@ typedef void (*each_submodule_fn)(const struct cache_entry *list_item, void *cb_data); +static void check_multi_worktree_support(void) +{ + char *worktree_config = get_worktree_config(the_repository); + if (!worktree_config) + die(_("submodules cannot be used with multiple " + "working trees unless the config\n" + "extension worktreeConfig is enabled. " + "Please read \"CONFIGURATION FILE\"\n" + "section in \"git help worktree\" for details")); + free(worktree_config); +} + static char *get_default_remote(void) { char *dest = NULL, *ret; @@ -2162,8 +2175,10 @@ static int module_config(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, module_config_options, git_submodule_helper_usage, PARSE_OPT_KEEP_ARGV0); - if (argc == 1 && command == CHECK_WRITEABLE) + if (argc == 1 && command == CHECK_WRITEABLE) { + check_multi_worktree_support(); return is_writing_gitmodules_ok() ? 0 : -1; + } /* Equivalent to ACTION_GET in builtin/config.c */ if (argc == 2) diff --git a/git-submodule.sh b/git-submodule.sh index 5e608f8bad..695939eff9 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -288,7 +288,7 @@ or you are unsure what this means choose another name with the '--name' option." esac ) || die "$(eval_gettext "Unable to checkout submodule '\$sm_path'")" fi - git config submodule."$sm_name".url "$realrepo" + git config --worktree submodule."$sm_name".url "$realrepo" git add --no-warn-embedded-repo $force "$sm_path" || die "$(eval_gettext "Failed to add submodule '\$sm_path'")" @@ -302,18 +302,16 @@ or you are unsure what this means choose another name with the '--name' option." git add --force .gitmodules || die "$(eval_gettext "Failed to register submodule '\$sm_path'")" - # NEEDSWORK: In a multi-working-tree world, this needs to be - # set in the per-worktree config. if git config --get submodule.active >/dev/null then # If the submodule being adding isn't already covered by the # current configured pathspec, set the submodule's active flag if ! git submodule--helper is-active "$sm_path" then - git config submodule."$sm_name".active "true" + git config --worktree submodule."$sm_name".active "true" fi else - git config submodule."$sm_name".active "true" + git config --worktree submodule."$sm_name".active "true" fi } diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh new file mode 100755 index 0000000000..3ee5380e88 --- /dev/null +++ b/t/t2405-worktree-submodules.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +test_description='multiple worktrees as superprojects' + +. ./test-lib.sh + +test_expect_success 'set up submodule source' ' + test_create_repo submodsrc && + ( + cd submodsrc && + test_commit one + ) && + test_commit initial && + git worktree add -b secondary secondary HEAD && + git config extensions.worktreeConfig true +' + +test_expect_success 'add submodules' ' + SRC="$(pwd)/submodsrc" && + git submodule add "$SRC" sub1 && + git commit -m sub1 && + git -C secondary submodule add "$SRC" sub2 && + git -C secondary commit -m sub2 && + + git config --get-regexp "submodule.*" | sort >actual1 && + cat >expected1 <<-EOF && + submodule.sub1.active true + submodule.sub1.url $(pwd)/submodsrc + EOF + test_cmp expected1 actual1 && + test -d .git/modules/sub1 && + + git -C secondary config --get-regexp "submodule.*" | sort >actual2 && + cat >expected2 <<-EOF && + submodule.sub2.active true + submodule.sub2.url $(pwd)/submodsrc + EOF + test_cmp expected2 actual2 && + test -d .git/worktrees/secondary/modules/sub2 +' + +test_done From patchwork Wed Jan 16 10:31:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC9D66C2 for ; Wed, 16 Jan 2019 10:32:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC0072CF8C for ; Wed, 16 Jan 2019 10:32:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B09032CF9C; Wed, 16 Jan 2019 10:32:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C76F2CF8C for ; Wed, 16 Jan 2019 10:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404124AbfAPKcb (ORCPT ); Wed, 16 Jan 2019 05:32:31 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45544 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKca (ORCPT ); Wed, 16 Jan 2019 05:32:30 -0500 Received: by mail-pg1-f196.google.com with SMTP id y4so2642780pgc.12 for ; Wed, 16 Jan 2019 02:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nIk9BOlvOrOPVhAeryZlwC53d+4V9mjhIjKaVE4th9w=; b=i7dVzkNzLWAsxQgp1M+CsYqc9A6alsaERJ09XvBjlhvrSHKKd9jeNqZe041KkziqjU qy6aFH3DtKTL/OpUUf9zDMQw5wqhRYjUibctRH4e0EmtM/Sun17UxgQOd7OYSDkvP8+6 5D8KqpH220G4WtOEJd9/rvvYtIXAmL6AVnJ6oeotzL0qlNrOGV0z88M0te89ZOgTiLK9 o5uGfFCnmotYOkGAzqoNu8TgE5uBa6Mdi2c0VkgPP4srafL++NxYIfQropcXi8qi8DEF Ec7GZxCfNK64hmnlXAuCpA3z28QjpXzkpdHzLKUj4YB85p1eCnuX31scdRo2ZMFWBz9p bSeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nIk9BOlvOrOPVhAeryZlwC53d+4V9mjhIjKaVE4th9w=; b=Ek3w5dL3tHU2a2R2D5SrssCc71n/UGj7+6tlyFtwOBlcL59wq/Cqe8OrK6RqB37926 JkCckX6jUUicksBCum0Y5F/4o9keXataj++YW/iBc4eLTI0hOXWdea0at0QMU7Ho6nKP ucgWD64JRzVEmHJskTZGIIj8WuVTfzaRxiSVxDP+THQh5WHIR7fzXXDWeY9vSgTJeR8Q 1p+OEK+TaqktEHaZV4qE8dy5sscoYyWeDS3Al1RYRduYrCmhnPtv3qBu7Y0u7PUbqH8x KX6nPyH8Zbp1v11NVCesLJePUtwS7XjdEnyygmx2TPva1NJRkC4BnNAOxFpX+xOFWzvG viIQ== X-Gm-Message-State: AJcUukeX9slKjmYp7qElNhVC7IlwR7V04S2Fz5ihrHhbwBvLQU31pv63 aZ6z7NCbH18ELiduPZ5wz212O+oe X-Google-Smtp-Source: ALg8bN4p4nUjAbevOQ9GDScYlRo+SOqniVWuXHqE1mMHAMK9sMnQ2oJT7A+AmE2zhgnvVKNY6ajgkw== X-Received: by 2002:a62:220d:: with SMTP id i13mr9026491pfi.162.1547634749553; Wed, 16 Jan 2019 02:32:29 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 125sm9451716pfg.39.2019.01.16.02.32.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:28 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:24 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 04/10] submodule init: support multiple worktrees Date: Wed, 16 Jan 2019 17:31:53 +0700 Message-Id: <20190116103159.9305-5-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The entire submodule section in the superproject will be per-worktree and written to $GIT_DIR/config.worktree. The behavior when you only have one worktree (and not enabled extensions.worktreeConfig) is the same as before, everything is still written in $GIT_DIR/config Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 14 +++++--------- t/t2405-worktree-submodules.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 7b328ec060..6b749b41fb 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -639,15 +639,11 @@ static void init_submodule(const char *path, const char *prefix, die(_("No url found for submodule path '%s' in .gitmodules"), displaypath); - /* - * NEEDSWORK: In a multi-working-tree world, this needs to be - * set in the per-worktree config. - * - * Set active flag for the submodule being initialized - */ + check_multi_worktree_support(); + if (!is_submodule_active(the_repository, path)) { strbuf_addf(&sb, "submodule.%s.active", sub->name); - git_config_set_gently(sb.buf, "true"); + repo_config_set_worktree_gently(the_repository, sb.buf, "true"); strbuf_reset(&sb); } @@ -672,7 +668,7 @@ static void init_submodule(const char *path, const char *prefix, free(oldurl); } - if (git_config_set_gently(sb.buf, url)) + if (repo_config_set_worktree_gently(the_repository, sb.buf, url)) die(_("Failed to register url for submodule path '%s'"), displaypath); if (!(flags & OPT_QUIET)) @@ -693,7 +689,7 @@ static void init_submodule(const char *path, const char *prefix, } else upd = xstrdup(submodule_strategy_to_string(&sub->update_strategy)); - if (git_config_set_gently(sb.buf, upd)) + if (repo_config_set_worktree_gently(the_repository, sb.buf, upd)) die(_("Failed to register update mode for submodule path '%s'"), displaypath); } strbuf_release(&sb); diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh index 3ee5380e88..2ee3e2d039 100755 --- a/t/t2405-worktree-submodules.sh +++ b/t/t2405-worktree-submodules.sh @@ -39,4 +39,32 @@ test_expect_success 'add submodules' ' test -d .git/worktrees/secondary/modules/sub2 ' +test_expect_success 'init submodules' ' + git clone --no-local .git cloned && + ( + cd cloned && + git config extensions.worktreeConfig true && + git submodule init sub1 && + git worktree add secondary origin/secondary && + cd secondary && + git submodule init sub2 + ) && + + git -C cloned config --get-regexp "submodule.*" | sort >actual1 && + cat >expected1 <<-EOF && + submodule.sub1.active true + submodule.sub1.url $(pwd)/submodsrc + EOF + test_cmp expected1 actual1 && + ! test -d cloned/.git/modules/sub1 && + + git -C cloned/secondary config --get-regexp "submodule.*" | sort >actual2 && + cat >expected2 <<-EOF && + submodule.sub2.active true + submodule.sub2.url $(pwd)/submodsrc + EOF + test_cmp expected2 actual2 && + ! test -d cloned/.git/worktrees/secondary/modules/sub2 +' + test_done From patchwork Wed Jan 16 10:31:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCAB913BF for ; Wed, 16 Jan 2019 10:32:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC4252CF6F for ; Wed, 16 Jan 2019 10:32:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B08962CF94; Wed, 16 Jan 2019 10:32:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EEB72CF6F for ; Wed, 16 Jan 2019 10:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404127AbfAPKcg (ORCPT ); Wed, 16 Jan 2019 05:32:36 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46405 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcg (ORCPT ); Wed, 16 Jan 2019 05:32:36 -0500 Received: by mail-pl1-f196.google.com with SMTP id t13so2815886ply.13 for ; Wed, 16 Jan 2019 02:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LUFeZLILBeS+Ryj4f65cmbP2ZeOc4mcMnECFLM+nhUc=; b=BwgCR0sSblyvLToYpxDP+1hrD0T9dep1f0+AsGLcl51NRtDJi5r4Xwc1+rFkxiCHIv Pwb53BWYF6A1ECNvgQV2hscT+Om2nv87GsG/58Mdh/0GWbbqHJWrq+RD5jMqYyQDjjxd qbvW7ukwuaVv5jRuRsSobwMzA5DKMQd6y6MmJiisbGF0YFBh4XxaQWSCbuE9lRPCfyBl Tee1jkaaSkHwvyNGZIfFOTJyn0ANR732SJv+6MLqSGY8FF7j39j9Q56aTEGdb9lK+Qhn 9Ky+X8oAvxPSXo8IzQSIbl0ECNSjXBYrevilSP6e5ZdMk9acErI2I+3gghR/Wf7c5HvA XJ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LUFeZLILBeS+Ryj4f65cmbP2ZeOc4mcMnECFLM+nhUc=; b=axOExP+6K6j3UwjVcIoht7iCZSwl8kuVns7ylkzEY/iAgDu+kOsjaKFcViasrssW1H z4p+WiEKnG8Ad1/dNtPQ8Cuf0WeMi4tdmt/a1qacCX74Tjm8DrD5Hy92nMN2nGLXaHqL SdTBCHdFUAKMesPkyciSLZRxLa5lDEbr6qhe7ptEBcGVYYOhuKv7wBUK2fL5SPa4houU z5shrhgJfzBQSJ7XoasfMcduoCxla484knifMASm3gz6RqVvBu/4jn9lfxU1VLzNfZ4+ 8XufFrG4RuIsU97zOM52uWs4Ox802wjo/8igjQSv1vlghTzJlKMSwlfO5VH9GO35uYeh etSg== X-Gm-Message-State: AJcUukcEQmESP/rdd1beitwnDd2xtN0lGgaXN6OOa2ndP1gnUZO9/Q27 Yn4cCDDAHKUh1ObVBiPG2R6m8VYM X-Google-Smtp-Source: ALg8bN5wtJQ+nJLVQLlnauV0oOxrehKlG1jZp8FA02POhCSSlOufxL5hE/a6u7o4K5KA3brngnQw5w== X-Received: by 2002:a17:902:43e4:: with SMTP id j91mr8963660pld.147.1547634755299; Wed, 16 Jan 2019 02:32:35 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id y12sm9314595pfk.70.2019.01.16.02.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:34 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:29 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 05/10] submodule update: add tests for multiple worktrees Date: Wed, 16 Jan 2019 17:31:54 +0700 Message-Id: <20190116103159.9305-6-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are no changes needed for 'submodule update'. The clones will be per-worktree and all the support is already in place. Add a test to make sure it actually works. Signed-off-by: Nguyễn Thái Ngọc Duy --- t/t2405-worktree-submodules.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh index 2ee3e2d039..c1b19ad613 100755 --- a/t/t2405-worktree-submodules.sh +++ b/t/t2405-worktree-submodules.sh @@ -67,4 +67,15 @@ test_expect_success 'init submodules' ' ! test -d cloned/.git/worktrees/secondary/modules/sub2 ' +test_expect_success 'update submodules' ' + ( + cd cloned && + git submodule update sub1 && + cd secondary && + git submodule update sub2 + ) && + test -d cloned/.git/modules/sub1 && + test -d cloned/.git/worktrees/secondary/modules/sub2 +' + test_done From patchwork Wed Jan 16 10:31:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BEA413BF for ; Wed, 16 Jan 2019 10:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A36B2CF6F for ; Wed, 16 Jan 2019 10:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E5BA2CF94; Wed, 16 Jan 2019 10:32:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F07F42CF6F for ; Wed, 16 Jan 2019 10:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404153AbfAPKcm (ORCPT ); Wed, 16 Jan 2019 05:32:42 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46913 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcm (ORCPT ); Wed, 16 Jan 2019 05:32:42 -0500 Received: by mail-pf1-f195.google.com with SMTP id c73so2862290pfe.13 for ; Wed, 16 Jan 2019 02:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ol+wViqE8ObUVWj8YOJCZuKfHYIe3CDHUcXoJVNNB3U=; b=sBz5wumLCe9gpskpYlhj1iSj+9pt9deT3xPX8KfaMaYWm32YbRLY9qoi87NFE4+PWk KOkM9KJgWWuKV3iDDS4yxED85pmyD2sR+WccgFaanAFJcqXKyuwN1SrBfzFm0PC47JOf OEa06NmVn1rLlbPpxk2qYmfTR3OMyxZYy7ugpQlLG6r9GCZIoMIwfrRpYppCNHo24axE CfWTnm9/1A1OQIVMEjaeXuxbF4cX3NUdbTryAksUeoA2jcb1Xv2eU+nTE49rvxPHRgPD oJeRFhhB0wIAsD59Vl2QcOzlMTUvS2cLlTHJKr+SGOe3+8SpgoGq/yqCUtrgo2KbmevE S4cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ol+wViqE8ObUVWj8YOJCZuKfHYIe3CDHUcXoJVNNB3U=; b=sd5VUTRnJruNbdqp0WealMFux3OMK6Luj7tpw4QZ/06HKO0J1tuY0H3ZhJjDyQSTe0 khpzHAC79ymAQ5LOsEy157bUJAtHBxW6VC2OJImi+oDVSjaz66JKL4PCrAyoD55gjsqs /OyxuAPhZU0rtWA2UjsqCmJ405Kak9w5AD6Eevh4pqwKvgRjFcrfYYcoZ11g4ohpVYUR 21+LF8BHd08Uv/aIuCjhKIIDRZxZ2Yg/64FR4jcbgI0oykFRoKomW6l8ArUWG6Ei0eph GX4xkATUV61z8jUs99H4P6EvSsVnK/2/brzliZpi3gk1r8QYMrz8R6/B37I/txFcc7/v 6LPA== X-Gm-Message-State: AJcUukega20TPLAyJcB4jPHk0eMhg1Urw2jhnAF+8FjTEEqql1+2UMaY J8/sqc4j3R73OtBXCCQPDG5KqryW X-Google-Smtp-Source: ALg8bN7EdVsZCzpbqHXmnH4kp49d0XJy5M+GF3RdQbHOEvTi6Hte3yZZWei7zrl5R9G6mnl4MUaOPQ== X-Received: by 2002:a63:d104:: with SMTP id k4mr7989317pgg.227.1547634761022; Wed, 16 Jan 2019 02:32:41 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 84sm16750626pfa.115.2019.01.16.02.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:40 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:35 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 06/10] submodule sync: support multiple worktrees Date: Wed, 16 Jan 2019 17:31:55 +0700 Message-Id: <20190116103159.9305-7-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 12 +++++++----- t/t2405-worktree-submodules.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 6b749b41fb..288858af83 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -939,6 +939,7 @@ static void sync_submodule(const char *path, const char *prefix, struct strbuf sb = STRBUF_INIT; struct child_process cp = CHILD_PROCESS_INIT; char *sub_config_path = NULL; + struct repository subrepo; if (!is_submodule_active(the_repository, path)) return; @@ -979,7 +980,7 @@ static void sync_submodule(const char *path, const char *prefix, strbuf_reset(&sb); strbuf_addf(&sb, "submodule.%s.url", sub->name); - if (git_config_set_gently(sb.buf, super_config_url)) + if (repo_config_set_worktree_gently(the_repository, sb.buf, super_config_url)) die(_("failed to register url for submodule path '%s'"), displaypath); @@ -1000,14 +1001,15 @@ static void sync_submodule(const char *path, const char *prefix, strbuf_strip_suffix(&sb, "\n"); remote_key = xstrfmt("remote.%s.url", sb.buf); - strbuf_reset(&sb); - submodule_to_gitdir(&sb, path); - strbuf_addstr(&sb, "/config"); + if (repo_submodule_init(&subrepo, the_repository, path)) + die(_("could not get a repository handle for submodule '%s'"), path); - if (git_config_set_in_file_gently(sb.buf, remote_key, sub_origin_url)) + if (repo_config_set_worktree_gently(&subrepo, remote_key, sub_origin_url)) die(_("failed to update remote for submodule '%s'"), path); + repo_clear(&subrepo); + if (flags & OPT_RECURSIVE) { struct child_process cpr = CHILD_PROCESS_INIT; diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh index c1b19ad613..55daace672 100755 --- a/t/t2405-worktree-submodules.sh +++ b/t/t2405-worktree-submodules.sh @@ -78,4 +78,37 @@ test_expect_success 'update submodules' ' test -d cloned/.git/worktrees/secondary/modules/sub2 ' +test_expect_success 'sync submodules' ' + sed s/submodsrc/crsdombus/ .gitmodules >temp && + mv temp .gitmodules && + git submodule sync && + ( + cd secondary && + sed s/submodsrc/crsdombus/ .gitmodules >temp && + mv temp .gitmodules && + git submodule sync + ) && + + git config --get-regexp "submodule.*" | sort >actual1 && + cat >expected1 <<-EOF && + submodule.sub1.active true + submodule.sub1.url $(pwd)/crsdombus + EOF + test_cmp expected1 actual1 && + + git -C secondary config --get-regexp "submodule.*" | sort >actual2 && + cat >expected2 <<-EOF && + submodule.sub2.active true + submodule.sub2.url $(pwd)/crsdombus + EOF + test_cmp expected2 actual2 +' + +test_expect_success 'reset sync submodules' ' + git checkout -- .gitmodules && + git submodule sync && + git -C secondary checkout -- .gitmodules && + git -C secondary submodule sync +' + test_done From patchwork Wed Jan 16 10:31:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C58A36C2 for ; Wed, 16 Jan 2019 10:32:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4ED02CF6F for ; Wed, 16 Jan 2019 10:32:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A97632CF94; Wed, 16 Jan 2019 10:32:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90EA52CF6F for ; Wed, 16 Jan 2019 10:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404156AbfAPKct (ORCPT ); Wed, 16 Jan 2019 05:32:49 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44314 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcs (ORCPT ); Wed, 16 Jan 2019 05:32:48 -0500 Received: by mail-pg1-f196.google.com with SMTP id t13so2644671pgr.11 for ; Wed, 16 Jan 2019 02:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=raBf4rrOnQDclOt2Ra7rjfRUnq9y0VAz+PqI4s2K8U4=; b=iPYvtDwwoV7LJBlN6mZnldIARh2yWInvwq1+PW//morOPh3WPed4DIu+XwWkTO3MT4 m9i7znl1WE6rFxU9xBb330/uzXHPV8qg37lB1ZC7Y6VXE8AC1mka3yLhcsFF5qegSZx6 Lcj83CeKJ+pRPPIz+kfE3kGjO103gHT/FaiqYYi/nKwtfB2Xu0C+GBPhgl0MJcogU5Ap 3tSZOJgx1fLEAcy3/m/CeUKWIWmJ5iz8bTWXyJmxRSwycHkaVbaKJkB8uwq4qOuq5fEp nlZPkFTiaNZpFQz853sH0OvPYCK/UoWTIyR0vQOWNaHqht/q6RBgauWIfiOIoG7wiewC FZ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=raBf4rrOnQDclOt2Ra7rjfRUnq9y0VAz+PqI4s2K8U4=; b=SvuxnjJuQN7A4nt9yRQb7KOqSmFczBoatc27KCVV5EA9mJAZlUOdU96zVyl/l+frOj eJKV047+fVgttkkPO9U7wpgWqlvcyZIgBhj0F4n18fi1iCWvpyNXQxB007HOS6HzidvQ VtWcBwL+O/z5LtuUATQUeBl3yhyixbn5gQx8HU3zScpqhV0sXU9bKim9S8YMkNE7XwoA 6GJYHG1EHbuLBrLFJ/vLfZ793qq1xx+2tbS/dvLXTJ9FxNBIJUL2XSyWTe5wq8dG16Qu YWhScZxjOKqgFephd5D/mu26Z+lqRB/FRZo5M4ng4xrauLXVD1WDzGRX4oyzTyUjEN9z V5sA== X-Gm-Message-State: AJcUukdaeaw6nM1gXdG1gF88CltE/fpZapaNSppuKFi0krfDa137kKT2 bmOH2QYjuOLunRKQMY0TFfVFr9xW X-Google-Smtp-Source: ALg8bN41lmogi6wULhQFliVvbvAgu5hMLdoGN3OfQ+jY9+sFadF8oQBDaKamU6/GmQRzzTduzJUDZQ== X-Received: by 2002:a65:4b82:: with SMTP id t2mr8225177pgq.189.1547634766882; Wed, 16 Jan 2019 02:32:46 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id d129sm9583543pfc.31.2019.01.16.02.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:46 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:41 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 07/10] submodule deinit: support multiple worktrees Date: Wed, 16 Jan 2019 17:31:56 +0700 Message-Id: <20190116103159.9305-8-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is the reverse of 'init' or 'add', config from superproject is removed from config.worktree (or just config in standard single worktree setup) Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 8 ++++++-- t/t2405-worktree-submodules.sh | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 288858af83..8943127ae7 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1097,6 +1097,8 @@ static void deinit_submodule(const char *path, const char *prefix, struct strbuf sb_config = STRBUF_INIT; char *sub_git_dir = xstrfmt("%s/.git", path); + check_multi_worktree_support(); + sub = submodule_from_path(the_repository, &null_oid, path); if (!sub || !sub->name) @@ -1150,21 +1152,23 @@ static void deinit_submodule(const char *path, const char *prefix, displaypath); cp_config.git_cmd = 1; - argv_array_pushl(&cp_config.args, "config", "--get-regexp", NULL); + argv_array_pushl(&cp_config.args, "config", "--worktree", "--get-regexp", NULL); argv_array_pushf(&cp_config.args, "submodule.%s\\.", sub->name); /* remove the .git/config entries (unless the user already did it) */ if (!capture_command(&cp_config, &sb_config, 0) && sb_config.len) { + char *config_file = get_worktree_config(the_repository); char *sub_key = xstrfmt("submodule.%s", sub->name); /* * remove the whole section so we have a clean state when * the user later decides to init this submodule again */ - git_config_rename_section_in_file(NULL, sub_key, NULL); + git_config_rename_section_in_file(config_file, sub_key, NULL); if (!(flags & OPT_QUIET)) printf(_("Submodule '%s' (%s) unregistered for path '%s'\n"), sub->name, sub->url, displaypath); free(sub_key); + free(config_file); } cleanup: diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh index 55daace672..8d53f639c9 100755 --- a/t/t2405-worktree-submodules.sh +++ b/t/t2405-worktree-submodules.sh @@ -111,4 +111,15 @@ test_expect_success 'reset sync submodules' ' git -C secondary submodule sync ' +test_expect_success 'deinit submodules' ' + git submodule deinit sub1 && + git -C secondary submodule deinit sub2 && + git config --get-regexp "submodule.*" | sort >actual1 && + test_must_be_empty actual1 && + test -d .git/modules/sub1 && + git -C secondary config --get-regexp "submodule.*" | sort >actual2 && + test_must_be_empty actual2 && + test -d .git/worktrees/secondary/modules/sub2 +' + test_done From patchwork Wed Jan 16 10:31:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 760C813BF for ; Wed, 16 Jan 2019 10:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65FAA2CF6F for ; Wed, 16 Jan 2019 10:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A58E2CF94; Wed, 16 Jan 2019 10:32:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5C4C2CF6F for ; Wed, 16 Jan 2019 10:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404161AbfAPKcy (ORCPT ); Wed, 16 Jan 2019 05:32:54 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34332 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKcy (ORCPT ); Wed, 16 Jan 2019 05:32:54 -0500 Received: by mail-pf1-f196.google.com with SMTP id h3so2896286pfg.1 for ; Wed, 16 Jan 2019 02:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gl3EMyC9TJQppvk98H59R/WIcNobqPlCuYMv+cf0QyM=; b=IFP8fQ9S01JkipzzuMnh8jOVqpIKIrYX7/KWMq/5WZKe60LbLK4xxFs/omNZOl3mpy pL/LwLmCqMu2v9GohzGn4jNIGJBdQZzZRN2zcVByT+y96y5mcVwROoDZtFucsiVZTvf4 15dWOuT/ftboe7p6/qgLE/smnA+H2iajJzYnJ6SXYYh3aHB1WmySNJgk6+CHiXdkPVUG jaSfUhhNE4J2Kk5AjI+MHtPjPS17QD6ONkT176HRE3ElKaZrQ8IEPe8MwNjOcssstYb/ de6PUq1VOGpvhD4CKDkj3I3OmwdGHnPxtEq3SvW7BPShX/dX/hsIJ8rEiOvQo+VziSe5 MX8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gl3EMyC9TJQppvk98H59R/WIcNobqPlCuYMv+cf0QyM=; b=GgOhJ4lOZGsHQLWwjyRGLDzrOsilWsNI/VHQZrpd8rvQT0S8wCDWjXZxC6PgjN0kn1 d6ujQ4KZHGqg9YR9y8BNAbQbouQIlQkLF4S18LUmTY9c4nm3+Y0KfD10Ag9wvHzQlW+X nKe9mdsTkhC8VU5CUj6UWLfsqdLHn1YAuVtiFjwda8iqyDy0RE4cuiZ+s4Ql5FmnxEDs XuqSvFzXhiQ6NJYStEYHLr2oOR3LIUTiX8mYRbhlrcHLxY42NZuXesxZURgrqoz77cOJ NkYwtFlANkJmb6kXOEX+oSNjJpK57MHT0rdUY7i7+Qp8s3oNk+HzxlZyGL3RTen++XZo Ca7A== X-Gm-Message-State: AJcUukc3RYfnCi8DaaJhA0uv3x/spY1k392Is4oJcWzbde8LtTCDpILp kjRzUikYMYbGcNx+qHmaP8RNTVWs X-Google-Smtp-Source: ALg8bN6HvFgP/a/8YJm84/+te/azPY1ZgQEi84glU9ixLH2Fvd5v6+PGTy6Qhhz2hzOoLBG5ITZ8jw== X-Received: by 2002:a63:b30f:: with SMTP id i15mr8293767pgf.240.1547634772868; Wed, 16 Jan 2019 02:32:52 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id l5sm5752168pgp.82.2019.01.16.02.32.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:52 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:47 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 08/10] submodule clone: use repo_config_set() Date: Wed, 16 Jan 2019 17:31:57 +0700 Message-Id: <20190116103159.9305-9-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid direct access to $SUBMODULE/config and do it through repo_config_set() instead. Note that repo_submodule_init() cannot be used because this early in the submodule initialization process, we may fail to get and parse .gitmodules with submodule_from_path(). Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 24 +++++++----------------- config.c | 10 ++++++++++ config.h | 1 + repository.c | 21 ++++++++++++++------- repository.h | 4 ++++ 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 8943127ae7..b5d74cd415 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1366,11 +1366,11 @@ static int module_clone(int argc, const char **argv, const char *prefix) const char *name = NULL, *url = NULL, *depth = NULL; int quiet = 0; int progress = 0; - char *p, *path = NULL, *sm_gitdir; + char *path = NULL, *sm_gitdir; struct strbuf sb = STRBUF_INIT; struct string_list reference = STRING_LIST_INIT_NODUP; int dissociate = 0; - char *sm_alternate = NULL, *error_strategy = NULL; + struct repository subrepo; struct option module_clone_options[] = { OPT_STRING(0, "prefix", &prefix, @@ -1443,27 +1443,17 @@ static int module_clone(int argc, const char **argv, const char *prefix) connect_work_tree_and_git_dir(path, sm_gitdir, 0); - p = git_pathdup_submodule(path, "config"); - if (!p) - die(_("could not get submodule directory for '%s'"), path); + if (repo_submodule_init_by_name(&subrepo, the_repository, path, name)) + die(_("could not get a repository handle for submodule '%s'"), path); /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */ - git_config_get_string("submodule.alternateLocation", &sm_alternate); - if (sm_alternate) - git_config_set_in_file(p, "submodule.alternateLocation", - sm_alternate); - git_config_get_string("submodule.alternateErrorStrategy", &error_strategy); - if (error_strategy) - git_config_set_in_file(p, "submodule.alternateErrorStrategy", - error_strategy); - - free(sm_alternate); - free(error_strategy); + repo_config_copy(&subrepo, the_repository, "submodule.alternateLocation"); + repo_config_copy(&subrepo, the_repository, "submodule.alternateErrorStrategy"); + repo_clear(&subrepo); strbuf_release(&sb); free(sm_gitdir); free(path); - free(p); return 0; } diff --git a/config.c b/config.c index 151d28664e..007436b382 100644 --- a/config.c +++ b/config.c @@ -2157,6 +2157,16 @@ void repo_config_set(struct repository *r, const char *key, const char *value) die(_("could not unset '%s'"), key); } +void repo_config_copy(struct repository *dst, struct repository *src, const char *key) +{ + char *value = NULL; + + repo_config_get_string(src, key, &value); + if (value) + repo_config_set(dst, key, value); + free(value); +} + int repo_config_set_worktree_gently(struct repository *r, const char *key, const char *value) { diff --git a/config.h b/config.h index 62204dc252..22edd96716 100644 --- a/config.h +++ b/config.h @@ -105,6 +105,7 @@ extern void git_config_set_in_file(const char *, const char *, const char *); extern int git_config_set_gently(const char *, const char *); extern int repo_config_set_gently(struct repository *, const char *, const char *); extern void repo_config_set(struct repository *, const char *, const char *); +extern void repo_config_copy(struct repository *dst, struct repository *src, const char *key); extern int repo_config_set_worktree_gently(struct repository *, const char *, const char *); extern void git_config_set(const char *, const char *); extern int git_config_parse_key(const char *, char **, int *); diff --git a/repository.c b/repository.c index 5dd1486718..f997bd1629 100644 --- a/repository.c +++ b/repository.c @@ -176,16 +176,23 @@ int repo_submodule_init(struct repository *submodule, const char *path) { const struct submodule *sub; + + sub = submodule_from_path(superproject, &null_oid, path); + if (!sub) + return -1; + return repo_submodule_init_by_name(submodule, superproject, + path, sub->name); +} + +int repo_submodule_init_by_name(struct repository *submodule, + struct repository *superproject, + const char *path, + const char *name) +{ struct strbuf gitdir = STRBUF_INIT; struct strbuf worktree = STRBUF_INIT; int ret = 0; - sub = submodule_from_path(superproject, &null_oid, path); - if (!sub) { - ret = -1; - goto out; - } - strbuf_repo_worktree_path(&gitdir, superproject, "%s/.git", path); strbuf_repo_worktree_path(&worktree, superproject, "%s", path); @@ -199,7 +206,7 @@ int repo_submodule_init(struct repository *submodule, */ strbuf_reset(&gitdir); strbuf_repo_git_path(&gitdir, superproject, - "modules/%s", sub->name); + "modules/%s", name); if (repo_init(submodule, gitdir.buf, NULL)) { ret = -1; diff --git a/repository.h b/repository.h index 9f16c42c1e..d3f0592471 100644 --- a/repository.h +++ b/repository.h @@ -119,6 +119,10 @@ int repo_init(struct repository *r, const char *gitdir, const char *worktree); int repo_submodule_init(struct repository *submodule, struct repository *superproject, const char *path); +int repo_submodule_init_by_name(struct repository *submodule, + struct repository *superproject, + const char *path, + const char *name); void repo_clear(struct repository *repo); /* From patchwork Wed Jan 16 10:31:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DD1D13BF for ; Wed, 16 Jan 2019 10:33:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C5D32CF8C for ; Wed, 16 Jan 2019 10:33:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D4AB2CF6F; Wed, 16 Jan 2019 10:33:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC2AC2CF6F for ; Wed, 16 Jan 2019 10:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389356AbfAPKdA (ORCPT ); Wed, 16 Jan 2019 05:33:00 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43009 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731929AbfAPKc7 (ORCPT ); Wed, 16 Jan 2019 05:32:59 -0500 Received: by mail-pg1-f196.google.com with SMTP id v28so2645492pgk.10 for ; Wed, 16 Jan 2019 02:32:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cpk6yQunThNTIG8rf1WgtCKj97UVbEDXKwiz6S60EWg=; b=kzOyktL/DvK0HxF2jZoHtwOmagrRHM11PtSFAyasr/6Bx7zPMPVFVT22ZnHPDJu5ho kQeFwXyZO44G4jJfQ6oBsaRoaWgRqF3oSqf06JwM6PC901TmVRaD+vLnDNYhqOP8/YXJ pQtFlMSRH0Ja6Ro4t0+cOBQsriX8h7bgiiBZIetzo7XEA1lU4x7YaAqTM1NHQIg9F3tT J+FU1nhqI0l4ZOKuULzmY6DocVAFFfBFsW3BEYVvGQPyrFzLZRAU5oW6SEO9ByKR06MG FSm5tbny6vMOHvm0qwWbtP2A4LdSI5mwqUSToJnTtNR1MuyOhNUno+SvXvLxhSqIG1au rJeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cpk6yQunThNTIG8rf1WgtCKj97UVbEDXKwiz6S60EWg=; b=moDvmXI+4wIuWOIObtd4WziDxo32U5md8Vb4qiR2cQtc4mklchIoyAyCjxlEouZR1I Nx0S4m7rAjvbrcoBhh3Hzl9FK6XA1e5tWOb6TZzW23RcH8mmw/OHBOPASBRY9cadHZek Zu94n7lSFh22xOXQ+ilDfFPkbOiTwlJr3w8gE8IszcB68GRb3cESnNK6yUgl9upUMpI9 SPaWZ/rdE+LDX10k+BAfgnrPwARuxUk+tTTFaZeOp+oGFtVTi04+rmWd6T3uF64dWS9j wteX5gH3Mfxh0uaFHoh2YCm6rfiUuWHUadvNGwTptHVfD4NousLbaiS0IYUYS4tRy88l iFQA== X-Gm-Message-State: AJcUukeBJwL8UKZrFJtvxcSpKCg86XJgYFYAIxL5YDrLDF6WHKSqEMXd GI9nF9lRXyZSit0w3exZcicYjDdq X-Google-Smtp-Source: ALg8bN6qmlEzNjgYGPYpnF38cw/4HHm4YVmrurpau92LNh6NyZXpNAiqTXdQwSut8eOXA4Y4mnhsgw== X-Received: by 2002:a65:534b:: with SMTP id w11mr8202767pgr.125.1547634778643; Wed, 16 Jan 2019 02:32:58 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id q199sm11182914pfc.97.2019.01.16.02.32.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:32:57 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:53 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 09/10] submodule clone: propagate extensions.worktreeConfig Date: Wed, 16 Jan 2019 17:31:58 +0700 Message-Id: <20190116103159.9305-10-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If this extension is already enabled on the superproject, the user likes to use multiple worktrees very much and is already aware of it. Enable it in submodules too so that when they want to make secondary submodule worktrees, they will not be worried about enabling it or migrating per-worktree config away. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index b5d74cd415..8a12d2f0ed 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1449,6 +1449,7 @@ static int module_clone(int argc, const char **argv, const char *prefix) /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */ repo_config_copy(&subrepo, the_repository, "submodule.alternateLocation"); repo_config_copy(&subrepo, the_repository, "submodule.alternateErrorStrategy"); + repo_config_copy(&subrepo, the_repository, "extensions.worktreeConfig"); repo_clear(&subrepo); strbuf_release(&sb); From patchwork Wed Jan 16 10:31:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10765713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B9E113BF for ; Wed, 16 Jan 2019 10:33:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A9E92CF8C for ; Wed, 16 Jan 2019 10:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F3322CF9C; Wed, 16 Jan 2019 10:33:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B51C52CF8C for ; Wed, 16 Jan 2019 10:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391916AbfAPKdH (ORCPT ); Wed, 16 Jan 2019 05:33:07 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33920 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389591AbfAPKdF (ORCPT ); Wed, 16 Jan 2019 05:33:05 -0500 Received: by mail-pg1-f195.google.com with SMTP id j10so2670156pga.1 for ; Wed, 16 Jan 2019 02:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MG4Dk+rDN502CyNBz06Nn2JLdINDNpRoYWEOCtKr/0I=; b=jw1Pw5ARh2vNguHx1GeG8x14Nq6tF5S+vIfl5ZdqP+SaAeuy++nqHol+284M8m8ukz JqwYYFbxaeSMlw2cS265ZUD3Sb3Ee6btmauA2fTfrxpCvmUItFVxiS2MRh+31rKUIfYH VcT35uMPj7yTN0E8iFiL/V+2a15S6XMPZ/eMuk+Zi6F/iD74ZRf8CoYjCBUXTj1Cz2fW 0Ornj/9ZPJ+Uu0n7slUP0CqPnw6b/AH42vICwQQAFvzHztK0I2jZKhkBlLJ2WCaMSBm3 wkSg4BO79i4fk0738PkpkbMxZ5EJQnrw2rx0tILLvh4MBYSsSVvcaQqSnLJMGc2+JPi2 58cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MG4Dk+rDN502CyNBz06Nn2JLdINDNpRoYWEOCtKr/0I=; b=kyxO8Hg/q2S5HKkEkdlcWv0yUX1fdIiul9aqw1q4mWhW9wHGyxBVjtxrmft6qDjlC5 buEW7g+xiW603Uv597aT2pnRXzM3+mmeB4Y0UUrYoENSDgNmrT3wHWeMacOLO5Wkji4n +y2ejAgtUV0w+Z7B53vYX8pln3GuKZSYZa20wKV1vWd8A69l/RvStK27GHy4TpJNNb4N Xa+HTCIT7lEpQU6CFgs/JEVX1MUD56vaG6mLvoFmqVOpk78Bxqa2kISyMP7VI6OdS1CA H74KZWynkkELOqYvSaTdcHk9eS3vVk7jd/+ZnAajefIKiWhGRhNg08DnjHzSFqh+x6f7 rBDA== X-Gm-Message-State: AJcUukfTyYXiBoqSzrCbhwX5z78aWoF4h3fOt4Tr7x2EPacbsBkgMEeo 0UgWvOZoR1l1+gRmerGF1sy0SGi+ X-Google-Smtp-Source: ALg8bN4CSGQHqFQWadXl6sh4bk0SU8OuHqQivwmr8EbtlCYyUG/dulvNOpYqnQ5eKrWSaXbHqNOLQg== X-Received: by 2002:a65:6491:: with SMTP id e17mr8138157pgv.418.1547634784450; Wed, 16 Jan 2019 02:33:04 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id m198sm8559138pga.10.2019.01.16.02.33.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 02:33:03 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 16 Jan 2019 17:32:58 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Stefan Beller , tsniatowski@vewd.com, Jonathan Nieder , marcnarc@xiplink.com, Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41j?= =?utf-8?b?IER1eQ==?= Subject: [PATCH 10/10] submodule ensure-core-worktree: write to config.worktree Date: Wed, 16 Jan 2019 17:31:59 +0700 Message-Id: <20190116103159.9305-11-pclouds@gmail.com> X-Mailer: git-send-email 2.20.0.482.g66447595a7 In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com> References: <20190116103159.9305-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use repo_config_set_worktree_gently() to write core.worktree. If the submodule has extensions.worktreeConfig on, the key will be in config.worktree instead of config file and not affect any new submodule's worktrees. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/submodule--helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 8a12d2f0ed..890de5902c 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2063,18 +2063,16 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix) die(_("could not get a repository handle for submodule '%s'"), path); if (!repo_config_get_string(&subrepo, "core.worktree", &cw)) { - char *cfg_file, *abs_path; + char *abs_path; const char *rel_path; struct strbuf sb = STRBUF_INIT; - cfg_file = repo_git_path(&subrepo, "config"); - abs_path = absolute_pathdup(path); rel_path = relative_path(abs_path, subrepo.gitdir, &sb); - git_config_set_in_file(cfg_file, "core.worktree", rel_path); + if (repo_config_set_worktree_gently(&subrepo, "core.worktree", rel_path)) + die(_("could not set '%s' to '%s'"), "core.worktree", rel_path); - free(cfg_file); free(abs_path); strbuf_release(&sb); }