From patchwork Fri Dec 14 23:59:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731857 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 5D97113AD for ; Sat, 15 Dec 2018 00:00:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F001A2D359 for ; Sat, 15 Dec 2018 00:00:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEA082D3DF; Sat, 15 Dec 2018 00:00:11 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 9D5422D415 for ; Sat, 15 Dec 2018 00:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728799AbeLOAAK (ORCPT ); Fri, 14 Dec 2018 19:00:10 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:56892 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAAJ (ORCPT ); Fri, 14 Dec 2018 19:00:09 -0500 Received: by mail-qk1-f201.google.com with SMTP id a199so6541228qkb.23 for ; Fri, 14 Dec 2018 16:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=bGA5JhhxJTxS0ciEl3O+WnPTg0gGWkpdDqUPP5su+z4=; b=qiVo+e728c3qySJauRpScfL4IyJdkY+RDsGkGfTwuqkslPdo0AljRM4rKznCujY1/R xdjZxJ+pCe+p+RTQoYFAC67mpIDbTUSXhDBcOhxHO80DPcUSsW2xwofJi/ZAbWlBtImt 2E5WHpveZc4l/KLexcg9Y91y8uw/0px4+1Pbw31D7KlhKhKkrro8gxUcv+sQEzrFJvAv qAR47fu+x+AYj11d549nqGaGbOtw0TXhpkwh89luvw+BYb7dwELJwS8q+bTDgFTiMT3n Ec6NOjNNKbxPNT88zGZrH6aDb+MI4YTWLp6466tnlg8xqieeKyOaV8VIfGqKzez3VhFt 2/FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bGA5JhhxJTxS0ciEl3O+WnPTg0gGWkpdDqUPP5su+z4=; b=nSDt4oLX/jg3dCC4wFM5DXNwAnQYVu8wPMnAJHeItjE48efyJo6csF765wtkGLy49L 6KucQf6gsXVQqXpD70/iRSIFtrPXBsgb1y11mlyO2GoGxR9yNFlZ7OoZFs5FXSDeHAZO 4lTqdCs+X0bvcwFt/MJFVr0m9gyZLXg8KpQTpRIDDSyxv31zaG4bE/1j/knStG9rLrxG D0JpwwfSUJViLsZ4+OsQyDQ8eD1vv5dpNxhUUZWeFCoznZZGlVzDEFIObqgwfmziQzVs ocm/dB3Qfusj2U66krcBUQC9KNFrcB5EbGj3aRQyYTxJzXXCQWz+2liocraOon/iFEdd r31A== X-Gm-Message-State: AA+aEWZSG1K0kxVIAXASaMkHl9zlGMAfh3GbythVME3nWC8/XAAlLquU U2u+1b5MJI2zXlASvVQa85r/TNMI1tg0 X-Google-Smtp-Source: AFSGD/Uc/hNuiqurDuWGjadFt69ySukuxvXKUz2Qpi7s16JFJgfX4neR9g5VFApZo1g4DKCoxZHVuFcD77Yz X-Received: by 2002:a37:2b0d:: with SMTP id r13mr4887637qkh.38.1544832008641; Fri, 14 Dec 2018 16:00:08 -0800 (PST) Date: Fri, 14 Dec 2018 15:59:42 -0800 In-Reply-To: <20181214235945.41191-1-sbeller@google.com> Message-Id: <20181214235945.41191-2-sbeller@google.com> Mime-Version: 1.0 References: <20181214235945.41191-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 1/4] submodule update: add regression test with old style setups From: Stefan Beller To: gitster@pobox.com Cc: git@vger.kernel.org, sbeller@google.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As f178c13fda (Revert "Merge branch 'sb/submodule-core-worktree'", 2018-09-07) was produced shortly before a release, nobody asked for a regression test to be included. Add a regression test that makes sure that the invocation of `git submodule update` on old setups doesn't produce errors as pointed out in f178c13fda. The place to add such a regression test may look odd in t7412, but that is the best place as there we setup old style submodule setups explicitly. Signed-off-by: Stefan Beller --- t/t7412-submodule-absorbgitdirs.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/t7412-submodule-absorbgitdirs.sh b/t/t7412-submodule-absorbgitdirs.sh index ce74c12da2..1cfa150768 100755 --- a/t/t7412-submodule-absorbgitdirs.sh +++ b/t/t7412-submodule-absorbgitdirs.sh @@ -75,7 +75,12 @@ test_expect_success 're-setup nested submodule' ' GIT_WORK_TREE=../../../nested git -C sub1/.git/modules/nested config \ core.worktree "../../../nested" && # make sure this re-setup is correct - git status --ignore-submodules=none + git status --ignore-submodules=none && + + # also make sure this old setup does not regress + git submodule update --init --recursive >out 2>err && + test_must_be_empty out && + test_must_be_empty err ' test_expect_success 'absorb the git dir in a nested submodule' ' From patchwork Fri Dec 14 23:59:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731859 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 DC96F1399 for ; Sat, 15 Dec 2018 00:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79BC02CC07 for ; Sat, 15 Dec 2018 00:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E1B52D3DD; Sat, 15 Dec 2018 00:00:14 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 5E12A2CC07 for ; Sat, 15 Dec 2018 00:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729077AbeLOAAM (ORCPT ); Fri, 14 Dec 2018 19:00:12 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:51637 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726772AbeLOAAL (ORCPT ); Fri, 14 Dec 2018 19:00:11 -0500 Received: by mail-pf1-f202.google.com with SMTP id q64so5669724pfa.18 for ; Fri, 14 Dec 2018 16:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QzPAjsWnTRfjGUXUWkmAjtVmCqnKCLZ1xUoMHOdTYSc=; b=SPSmrNiLhnbwXRUUGrOfAderxAftSc5X8XRO2Bi3HsH3gqKOxtGEWZe9stJ0+MZQcX foUYFkV0xA4b/W2ftFJ+JRExtcEGN14qoO0qyoeKvWxxIZDxIInRUhMnZFBcfXvUnwg/ +vKbI6l5ApFVlKWSZKbG1uRVEfI9TA4m8ofLadjT0PyMoUxcVLRu77fO82ruyYE0KN84 GlapnFrgCtDNKoBmNgNvxA1h9D1ZqFregTSDuGkvNqYrfvPa+ovnrdpus+gfK/dnBtsO gcqLQwwg4SphuA4jfTBH6VLUd8hugtD80IUGHKtvJDKNQqij0CLsO9Da9Npl9pNnLxw8 ayWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QzPAjsWnTRfjGUXUWkmAjtVmCqnKCLZ1xUoMHOdTYSc=; b=SR37ZNxQSchRdW+CLejcTX1rYInGSLn/izrBlDmv4Ga5vPBjpp1NiXlA+V3jEo89kf TVmaf1JVrT0zItmh7bj6EM09CxLuhlZWc59Pj3yncpuGxaPzjVn7lR3yas6E6/jydBVZ DFRZUlGuNr2o06CscLS4T7IxKbMYQTioPnHPSc8ZDV8qQSEYS4Q1dz+W8K9OH5W3qU59 Uc/EhIKrzFnNYx4cZ7JMDadmFbK04WDPnpmeL4fkdN6oo57MsBUimzw6clldYZYLgYsY av/NyFP2CA4AAn5VKiKAj5FB6NoFmUsC95UMhLObrRbNdLgG60gBwDIpvjGMZaubEDvr 18WQ== X-Gm-Message-State: AA+aEWbEst3QFVtk8dsJxHNcB0fCipWWLoQM4w+1lDDpM9GV8f8jt2QV 5Ie9Bus6Tx+bsuWIZLGabh3qCaL33YVY X-Google-Smtp-Source: AFSGD/U/O8fu9JpGCYLCtygUbV7PhhIkSIOqa34isXacIHOAl1YhF04fmSqER19f3TSg8R0Qf96p3e7/xiAV X-Received: by 2002:a62:5986:: with SMTP id k6mr2735453pfj.145.1544832010692; Fri, 14 Dec 2018 16:00:10 -0800 (PST) Date: Fri, 14 Dec 2018 15:59:43 -0800 In-Reply-To: <20181214235945.41191-1-sbeller@google.com> Message-Id: <20181214235945.41191-3-sbeller@google.com> Mime-Version: 1.0 References: <20181214235945.41191-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 2/4] submodule: unset core.worktree if no working tree is present From: Stefan Beller To: gitster@pobox.com Cc: git@vger.kernel.org, sbeller@google.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a submodules work tree is removed, we should unset its core.worktree setting as the worktree is no longer present. This is not just in line with the conceptual view of submodules, but it fixes an inconvenience for looking at submodules that are not checked out: git clone --recurse-submodules git://github.com/git/git && cd git && git checkout --recurse-submodules v2.13.0 git -C .git/modules/sha1collisiondetection log fatal: cannot chdir to '../../../sha1collisiondetection': \ No such file or directory With this patch applied, the final call to git log works instead of dying in its setup, as the checkout will unset the core.worktree setting such that following log will be run in a bare repository. This patch covers all commands that are in the unpack machinery, i.e. checkout, read-tree, reset. A follow up patch will address "git submodule deinit", which will also make use of the new function submodule_unset_core_worktree(), which is why we expose it in this patch. This patch was authored as 4fa4f90ccd (submodule: unset core.worktree if no working tree is present, 2018-06-12), which was reverted as part of f178c13fda (Revert "Merge branch 'sb/submodule-core-worktree'", 2018-09-07). The revert was needed as the nearby commit e98317508c (submodule: ensure core.worktree is set after update, 2018-06-18) is faulty and at the time of 7e25437d35 (Merge branch 'sb/submodule-core-worktree', 2018-07-18) we could not revert the faulty commit only, as they were depending on each other: If core.worktree is unset, we have to have ways to ensure that it is set again once the working tree reappears again. Now that 4d6d6ef1fc (Merge branch 'sb/submodule-update-in-c', 2018-09-17), specifically 74d4731da1 (submodule--helper: replace connect-gitdir-workingtree by ensure-core-worktree, 2018-08-13) is present, we already check and ensure core.worktree is set when populating a new work tree, such that we can re-introduce the commits that unset core.worktree when removing the worktree. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano Signed-off-by: Stefan Beller --- submodule.c | 14 ++++++++++++++ submodule.h | 2 ++ t/lib-submodule-update.sh | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/submodule.c b/submodule.c index 6415cc5580..d393e947e6 100644 --- a/submodule.c +++ b/submodule.c @@ -1561,6 +1561,18 @@ int bad_to_remove_submodule(const char *path, unsigned flags) return ret; } +void submodule_unset_core_worktree(const struct submodule *sub) +{ + char *config_path = xstrfmt("%s/modules/%s/config", + get_git_common_dir(), sub->name); + + if (git_config_set_in_file_gently(config_path, "core.worktree", NULL)) + warning(_("Could not unset core.worktree setting in submodule '%s'"), + sub->path); + + free(config_path); +} + static const char *get_super_prefix_or_empty(void) { const char *s = get_super_prefix(); @@ -1726,6 +1738,8 @@ int submodule_move_head(const char *path, if (is_empty_dir(path)) rmdir_or_warn(path); + + submodule_unset_core_worktree(sub); } } out: diff --git a/submodule.h b/submodule.h index a680214c01..9e18e9b807 100644 --- a/submodule.h +++ b/submodule.h @@ -131,6 +131,8 @@ int submodule_move_head(const char *path, const char *new_head, unsigned flags); +void submodule_unset_core_worktree(const struct submodule *sub); + /* * Prepare the "env_array" parameter of a "struct child_process" for executing * a submodule by clearing any repo-specific environment variables, but diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 016391723c..51d4555549 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -709,7 +709,8 @@ test_submodule_recursing_with_args_common() { git branch -t remove_sub1 origin/remove_sub1 && $command remove_sub1 && test_superproject_content origin/remove_sub1 && - ! test -e sub1 + ! test -e sub1 && + test_must_fail git config -f .git/modules/sub1/config core.worktree ) ' # ... absorbing a .git directory along the way. From patchwork Fri Dec 14 23:59:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731863 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 558671575 for ; Sat, 15 Dec 2018 00:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7F022D303 for ; Sat, 15 Dec 2018 00:00:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBBB32D33E; Sat, 15 Dec 2018 00:00: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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 676302D303 for ; Sat, 15 Dec 2018 00:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729906AbeLOAAT (ORCPT ); Fri, 14 Dec 2018 19:00:19 -0500 Received: from mail-qt1-f202.google.com ([209.85.160.202]:35048 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729815AbeLOAAS (ORCPT ); Fri, 14 Dec 2018 19:00:18 -0500 Received: by mail-qt1-f202.google.com with SMTP id p24so7354150qtl.2 for ; Fri, 14 Dec 2018 16:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=D7bzh1aKLksuqkZbb2ZIJMb4fJiu9WV17rk2PPP784U=; b=HGs5n3t7FKQdIY0P7Jc1VoaNw0LlKXEC9HpIIb5Z/tAwSpsIUriqTlQYVPhCpndBCg DZ8cvsgVcKzVTsvsSmPNcdqr+fHEFJMFMIv0nECfSn/majEayNu0KYuNwHWhUbTj36YL A0oQvvY7ouqOLNgZaxh1W+mOqdXYX6kp9ypgbm2K47p13zias6rcYRVXweStiWsYSHFe yzNRcO2TBdsYFWMCKTREixX+oYL7iluuO1vta95xYmcS3KFERsgwXk9l9SMEeRTm1zbk FNmnegpwuJfAqNSjP2CB/DHw7O0h8sIuwXLDdCP1SbmgD4u1cbBglxkgIVByuX4shWUy NDeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=D7bzh1aKLksuqkZbb2ZIJMb4fJiu9WV17rk2PPP784U=; b=sNwlYFmsSjbkP9ABlPZe0JPOicP/kBilx6phy7m9u9IEfzDtGVMhZOd4WS5TcspNK/ i60T9La8+fUeO9pOanUhZ0JMlZLOuYAnFZZPHK9nx56W3LF722z/Rs4Ng+6ywrfh7brl kp+qkIw5cI1p2FnoOpSHVY7YOfy1DpLszi4zxpoQuxXuuaRyDzj8xThRVW9KLOVWXpG9 ZrM+GoiM3574BdNKBW52BAOVMZYJFQoo4bbQO/Kr860i154PKanGuXvYUzJdj8V8mis3 hmSg5nuLF7IuYKToQX8U1AzJ72h8v0w91tgNIOiPghev1NVQShU7fgpjqEc9H+u6iJGi URQQ== X-Gm-Message-State: AA+aEWZW8BjUXnURr58w3ai7fb4e5WAV0nJKTXcEmdMOoDxjkNyKmYFW O5bMIGpYG84Pkk5PfvHy1FuC/LnRNXR8 X-Google-Smtp-Source: AFSGD/U6Zf0IL4ssqEJcuy3w6DOn3gHnU3aqhofKMLxI74v1jAN0FswEtIRhPpb62EktE1ffhoGQFF4vz9cU X-Received: by 2002:ac8:7244:: with SMTP id l4mr4928966qtp.21.1544832014248; Fri, 14 Dec 2018 16:00:14 -0800 (PST) Date: Fri, 14 Dec 2018 15:59:44 -0800 In-Reply-To: <20181214235945.41191-1-sbeller@google.com> Message-Id: <20181214235945.41191-4-sbeller@google.com> Mime-Version: 1.0 References: <20181214235945.41191-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 3/4] submodule--helper: fix BUG message in ensure_core_worktree From: Stefan Beller To: gitster@pobox.com Cc: git@vger.kernel.org, sbeller@google.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 74d4731da1 (submodule--helper: replace connect-gitdir-workingtree by ensure-core-worktree, 2018-08-13) missed to update the BUG message. Fix it. Signed-off-by: Stefan Beller --- 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..31ac30cf2f 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2045,7 +2045,7 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix) struct repository subrepo; if (argc != 2) - BUG("submodule--helper connect-gitdir-workingtree "); + BUG("submodule--helper ensure-core-worktree "); path = argv[1]; From patchwork Fri Dec 14 23:59:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Beller X-Patchwork-Id: 10731861 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 EB71913AD for ; Sat, 15 Dec 2018 00:00:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 873BD2D320 for ; Sat, 15 Dec 2018 00:00:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BC5C2D33E; Sat, 15 Dec 2018 00:00: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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 667AA2D320 for ; Sat, 15 Dec 2018 00:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729895AbeLOAAS (ORCPT ); Fri, 14 Dec 2018 19:00:18 -0500 Received: from mail-pf1-f201.google.com ([209.85.210.201]:48368 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729803AbeLOAAR (ORCPT ); Fri, 14 Dec 2018 19:00:17 -0500 Received: by mail-pf1-f201.google.com with SMTP id t2so5695281pfj.15 for ; Fri, 14 Dec 2018 16:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=giZsMHf0NVPWJB3VzkMWpUCMdUOA4dq377/B7d5AAEc=; b=Nm8D0rWgw7vsaf/3O3nJE8flENj/pltSkKidC4RCEIOe2w2vzIKv0k0a/6ghExmC0G SQ2jbaCietsm5c1ngUz61jazYF8ZactvBp+p2SU4+5J2F3LqJnS6y4xRLi/fHeNyy/FZ kNIxUvqIzSNcJXbaX5fiAgpJSI32MDdn66iL5DU3g+F20onS6jpSoR5GBaax1a1n/4rh yTIO637YCZBwLfRWdk3Lc9j7nrBFlXF+kHIJoaBzBThdxT1GM03mBeZ4/4VrASJ/3S0Y cX8nLLXKwYH0BAzCYIZ+67RdpSorgOea8O6iwjvxpxm3KqboUpiKiYc+mujPVZwDpXp5 bZ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=giZsMHf0NVPWJB3VzkMWpUCMdUOA4dq377/B7d5AAEc=; b=bpQycWkFDZw2o4ys1HP7b9xta9wHpqxoG/LOiT50k5GThSeIVk63u+gA1t9TJehzRf sCZBJnQvT5QzZEaYdvw5yCKnwexknCCfubOIpoY+ot6+L37gx7EkMVvqAomqmF8MZ5gn wrD4D0PxxL59oq0U+yrc84FcDCx8WgThwHvxz4LA9DetO7/IYxAYtFfKGO+tQIcwVQhb rAXpT3M2eFZR6rFInXjhRvL1dgLD94ohGkgvCRDHRTz0Y5l8hKd7eiryJ32bDK7cu+O3 GF3unul1XnGtxuxa5KKWVK4RQRZkEZozWwJufMWrrsEbx6TR7nuhFXz8rFOXA4FuMqp9 FZDg== X-Gm-Message-State: AA+aEWZ64UZJph/7Bo3gqNIZ/vwQ3qOeuYYO+lAosZbxXxHfIhFnBvhG pAGA78kOLv4RHSgnYPvSsyH5iameusCr X-Google-Smtp-Source: AFSGD/Ukv0RcQP3xvW4HXQhLvpXpgXND2ApcR2OLbF88jKoNk/lVKEh0DhHnyxv7af6PaXCgmBRXQ9cKBRsB X-Received: by 2002:a17:902:443:: with SMTP id 61mr2196516ple.31.1544832017295; Fri, 14 Dec 2018 16:00:17 -0800 (PST) Date: Fri, 14 Dec 2018 15:59:45 -0800 In-Reply-To: <20181214235945.41191-1-sbeller@google.com> Message-Id: <20181214235945.41191-5-sbeller@google.com> Mime-Version: 1.0 References: <20181214235945.41191-1-sbeller@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog Subject: [PATCH 4/4] submodule deinit: unset core.worktree From: Stefan Beller To: gitster@pobox.com Cc: git@vger.kernel.org, sbeller@google.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a submodule is deinit'd, the working tree is gone, so the setting of core.worktree is bogus. Unset it. As we covered the only other case in which a submodule loses its working tree in the earlier step (i.e. switching branches of top-level project to move to a commit that did not have the submodule), this makes the code always maintain core.worktree correctly unset when there is no working tree for a submodule. This re-introduces 984cd77ddb (submodule deinit: unset core.worktree, 2018-06-18), which was reverted as part of f178c13fda (Revert "Merge branch 'sb/submodule-core-worktree'", 2018-09-07) The whole series was reverted as the offending commit e98317508c (submodule: ensure core.worktree is set after update, 2018-06-18) was relied on by other commits such as 984cd77ddb. Keep the offending commit reverted, but its functionality came back via 4d6d6ef1fc (Merge branch 'sb/submodule-update-in-c', 2018-09-17), such that we can reintroduce 984cd77ddb now. Signed-off-by: Stefan Beller --- builtin/submodule--helper.c | 2 ++ t/lib-submodule-update.sh | 2 +- t/t7400-submodule-basic.sh | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 31ac30cf2f..672b74db89 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1131,6 +1131,8 @@ static void deinit_submodule(const char *path, const char *prefix, if (!(flags & OPT_QUIET)) printf(format, displaypath); + submodule_unset_core_worktree(sub); + strbuf_release(&sb_rm); } diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 51d4555549..5b56b23166 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -235,7 +235,7 @@ reset_work_tree_to_interested () { then mkdir -p submodule_update/.git/modules/sub1/modules && cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2 - GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree + # core.worktree is unset for sub2 as it is not checked out fi && # indicate we are interested in the submodule: git -C submodule_update config submodule.sub1.url "bogus" && diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 76a7cb0af7..aba2d4d6ee 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -984,6 +984,11 @@ test_expect_success 'submodule deinit should remove the whole submodule section rmdir init ' +test_expect_success 'submodule deinit should unset core.worktree' ' + test_path_is_file .git/modules/example/config && + test_must_fail git config -f .git/modules/example/config core.worktree +' + test_expect_success 'submodule deinit from subdirectory' ' git submodule update --init && git config submodule.example.foo bar &&