From patchwork Mon Feb 17 04:53:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11385211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA37A17F0 for ; Mon, 17 Feb 2020 04:53:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CADAA20725 for ; Mon, 17 Feb 2020 04:53:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rlLxjSlK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727931AbgBQExM (ORCPT ); Sun, 16 Feb 2020 23:53:12 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:38930 "EHLO mail-wr1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726656AbgBQExL (ORCPT ); Sun, 16 Feb 2020 23:53:11 -0500 Received: by mail-wr1-f45.google.com with SMTP id y11so17967540wrt.6 for ; Sun, 16 Feb 2020 20:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=aEkIEkwcD6BlECel7broWtl05by19Dvm49kA57KiyGc=; b=rlLxjSlKp8huRSlzD2BYqob/+Mq3dGtoJYyo+CXn8FgJfbS8s390cgh4YF1XLSYLs0 yCIrp1+0aJ9ExZ/hTxU1oZCv1ar8QjGkRQ5mQWjFcMd11kVc5A/1WBdykLJYhe2oiAoc 0BeVqosLVYMSoVelv+/G7tH+TTavsH6BOs/dWLS1khYFnoXNsnXrNaw6IS7/8kyGWwj7 gXRnJeH9b47/2Nxo9SHPRfT1uxUyJkEe6K2GUoFCRL6gNDPTEVjOhaYaMAG0zEWSTjse 9jLhaWajsp9b+/NFwE9XiAUc11LfR/yl7xVHTCo+wl0+vrrc6bCB3ZRnU6OdcM3z401t +41Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=aEkIEkwcD6BlECel7broWtl05by19Dvm49kA57KiyGc=; b=olknLuy/fVPwnc6l2T0Yg8KU+m4WFa0TcENixWe929VZfL+WfOxm5UMaiDOyVe6bBV 1BCFbYgy8/LfoNFjlUOzAwutm6uADRrPGxL6a1ob2cYoYbBBd04TizVhU/3SX/RL5x+n x+x5zXkS4+tiuHodpnrGQRBdU5p7rGUZb4970uJ3PmEICaaTF8ubrnQBDC0rqHgDYDvI AM+64YB+vwrsDuI0Oiy669QY/hx136KtGku/nxYFGiwNxNYLiIGMXR0YazyQcDoumHgY vacLqQWET+4ZTRffjOhRy4pRj/tQTzEwmR7iJDtqDKVQwX+abLyIBciNnFrIEnN2Tfe/ xmeA== X-Gm-Message-State: APjAAAUFlNcdKM37uRxpndbbs+qSHsNfZAyoqNzFbsBRTNuzG90EdMUv i/2udYK/BleJ3Kou3bM15Hm2137W X-Google-Smtp-Source: APXvYqx8aG3KHPzFlBi+mXFFfZu3iuc+f5AdKPIzjWwaLR4w0b3jvl9wdmnWzqXW100WlTwLaRajcw== X-Received: by 2002:adf:e906:: with SMTP id f6mr19319500wrm.258.1581915188023; Sun, 16 Feb 2020 20:53:08 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n13sm19437045wmd.21.2020.02.16.20.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 20:53:07 -0800 (PST) Message-Id: <5a271857a1176ede2ac9c894dcb436758e28a79f.1581915186.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Philippe Blain via GitGitGadget" Date: Mon, 17 Feb 2020 04:53:01 +0000 Subject: [PATCH 1/6] t7112: remove mention of KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Stefan Beller , Damien Robert , Philippe Blain , Philippe Blain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Philippe Blain The known failure mode KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED was removed from lib-submodule-update.sh in 218c883783 (submodule: properly recurse for read-tree and checkout, 2017-05-02) but at that time this change was not ported over to topic sb/reset-recurse-submodules, such that when this topic was merged in 5f074ca7e8 (Merge branch 'sb/reset-recurse-submodules', 2017-05-29), t7112-reset-submodules.sh kept a mention of this removed failure mode. Remove it now, as it does not mean anything anymore. Signed-off-by: Philippe Blain --- t/t7112-reset-submodule.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/t/t7112-reset-submodule.sh b/t/t7112-reset-submodule.sh index a1cb9ff858e..67346424a53 100755 --- a/t/t7112-reset-submodule.sh +++ b/t/t7112-reset-submodule.sh @@ -5,7 +5,6 @@ test_description='reset can handle submodules' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh -KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1 KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1 From patchwork Mon Feb 17 04:53:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11385203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DED3A1820 for ; Mon, 17 Feb 2020 04:53:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFE5C20726 for ; Mon, 17 Feb 2020 04:53:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vgg25Azg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbgBQExM (ORCPT ); Sun, 16 Feb 2020 23:53:12 -0500 Received: from mail-wm1-f42.google.com ([209.85.128.42]:55488 "EHLO mail-wm1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbgBQExK (ORCPT ); Sun, 16 Feb 2020 23:53:10 -0500 Received: by mail-wm1-f42.google.com with SMTP id q9so15735402wmj.5 for ; Sun, 16 Feb 2020 20:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=TUewa9qUUsuqkI6sg+OxwTSwOsjB3oT5CT+AIku0CCI=; b=Vgg25AzgaF7at+iN0U+ppofQlULAktK3ZI4MZrF7JrE/VUxVlsw8BEVDwLhjRIXZ06 66E2zqTk+ledf766Qoh0pNEsNgnbdLJPLNwRWLliq/wmGj+s/YE+ciTBkmf9cpenGvFA ZK8Knpz7pxwXkesQ0gHu1ywI/OnJHv3L47zexoCAc/14O7IRotQKjNRekd1vgjwB3okP eQOAUyQo6ffWO3KptGYpBxC2VahZZ4THeLpNvym5zlLJ62sp2O7CqKk8vO4DcdrMc82p nFstcsf/k65I3CUvTBWz9Gh45bdAqJqUMDee4bbmGhDHdklAjellQfDwWm70FoT6U568 MZWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=TUewa9qUUsuqkI6sg+OxwTSwOsjB3oT5CT+AIku0CCI=; b=gbalh+dh0AVJZ075P+bMuedG2F5ea2++nZoKmX+t3QmUf4hrvLYzl5nhAvqtdpL1Sy dtIqD28FcpV39M74+U30XIyhcCF/ZD0z5x08sDPH6BrBJ192uedWDe8GOWLk1GdxrDKp NNEa1CC4ZiczYb8fcfyfHWpLAFwn8lMmBtEaLromFmC4JnhFL6/NSE2/AUQWmwvs1hbi YiW6FMjcUcNl/a3qW0aFvb8btd7Xv8Q8wTyPrsq7RIdODPTr/bERlYLtbwZPKMXJfs3Y O1mSEtxDaIlSIVemYoc9TblyEmuYF79t1JPD3XO2JG8rkS0rWu+lPu/lekbVqC5WFOT1 HBUA== X-Gm-Message-State: APjAAAUcrD4W4cBW5WqqwRVDteIf7qoSBy0jYHAmHx5KiW0f+K0Cxsbp l0OHhigf/wq7bgRvmgCc5sILYj/T X-Google-Smtp-Source: APXvYqxa/oeOKfPPM9E4hQn++gtXrtoHFUjjnQ2XOF0vhG0P7Hn3v1+gY4BQLCECPPjbgd8c9U6W9w== X-Received: by 2002:a1c:bdc6:: with SMTP id n189mr20331756wmf.102.1581915188714; Sun, 16 Feb 2020 20:53:08 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d22sm18594602wmd.39.2020.02.16.20.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 20:53:08 -0800 (PST) Message-Id: <9004c95a72847615ded3d50779b80b77004df736.1581915186.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Philippe Blain via GitGitGadget" Date: Mon, 17 Feb 2020 04:53:02 +0000 Subject: [PATCH 2/6] t/lib-submodule-update: remove outdated test description Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Stefan Beller , Damien Robert , Philippe Blain , Philippe Blain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Philippe Blain The commands in the unpack_trees machinery (checkout, reset, read-tree) were fixed in 218c883783 (submodule: properly recurse for read-tree and checkout, 2017-05-02) to correctly update nested submodules when called with the `--recurse-submodules` flag. However, a comment in t/lib-submodule-update.sh mentions that this use case still doesn't work. Remove this outdated comment. Signed-off-by: Philippe Blain --- t/lib-submodule-update.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 1dd17fc03e1..5f9eb682f6a 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -908,7 +908,6 @@ test_submodule_switch_recursing_with_args () { ) ' - # recursing deeper than one level doesn't work yet. test_expect_success "$command: modified submodule updates submodule recursively" ' prolog && reset_work_tree_to_interested add_nested_sub && From patchwork Mon Feb 17 04:53:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11385213 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DB6D1820 for ; Mon, 17 Feb 2020 04:53:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2A8F20725 for ; Mon, 17 Feb 2020 04:53:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DPXLUxc4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbgBQExQ (ORCPT ); Sun, 16 Feb 2020 23:53:16 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34683 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726656AbgBQExN (ORCPT ); Sun, 16 Feb 2020 23:53:13 -0500 Received: by mail-wr1-f68.google.com with SMTP id n10so16037575wrm.1 for ; Sun, 16 Feb 2020 20:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=lnsT90haYi8aXQv2xc7ovgJBe4ZUQqvZxZRum5GQbr4=; b=DPXLUxc4HdJ6IvRPmf/xnPzNNiMKdTmnRRUhoi/kNFBBtGPGkkZMfPMH/Ul+2J0j4Y lOw1A+hGGFmX9CYVpcCrfGvxxZeAgnwJPZXm4hCcWbPLAIwcm8+VioQQEq6/jakZa/5J xQzLIpJRXjnsjin1FYHEXTJw5IMLISOV2mKl6SN5pJyRo050vPdIkjd4/HZvIA5WbUMA C8MVtVpuYqq7L5dD/Hqai7lggRd3B7fOkFxdbrq5lxnBh76N9Fp3wx8uCC/E6Dc5CQxs pE0Wei9oAluIOeP86Akgh60o0TG9eyb6uN8E7cmqjk/EL50FrWEOsQgeWxnDbf2XgtQy BAUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=lnsT90haYi8aXQv2xc7ovgJBe4ZUQqvZxZRum5GQbr4=; b=JL2b+M30Ezw++qKcE/oEdp9tQO0p2JYn383uk4f1IXZ149L50Stv0IHFeCLnKg2ee5 mSoQFraDRRMgzgtL5HGaA/vi03TBQmzp4RW2/MBL5neInetI9ASCnKhgXzI4gQfK/Nva +8PkTa3S3gJqWWRqp0k1r8W3rwJ7DvYxCmi2ws86ub4JQvg4+UKD+NFvBpJsPejlv5o4 FpZkc2D3fZjws7/RkpNOzPaOcZ+gCIOUDJmeCHsGPftxn5RuHZIdJCBLI5AhoLW/f67Y t8tBU9DLyLgXWvqRPFB/RfKD0m2Vddux1o/1fGiqprnByBF8D/HYfrrMcfDP9E8Ed1o/ M3DQ== X-Gm-Message-State: APjAAAVjJR/ah/nNX0LRJU2wp2yi+u0E1ql3Bb6yden5OmFTjXyoUHgH DzX7mXyv3kBTw82Xt/gvWr4chXHS X-Google-Smtp-Source: APXvYqy98+Pwz6pfnpdf9WrtM5Y1M9x1RCkMTxRI9Ezwyl+6CyIrXURZjkLEpL537xHsrMK3E5U4iw== X-Received: by 2002:adf:ee0b:: with SMTP id y11mr19198907wrn.62.1581915189447; Sun, 16 Feb 2020 20:53:09 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c77sm18463753wmd.12.2020.02.16.20.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 20:53:09 -0800 (PST) Message-Id: In-Reply-To: References: From: "Philippe Blain via GitGitGadget" Date: Mon, 17 Feb 2020 04:53:03 +0000 Subject: [PATCH 3/6] t/lib-submodule-update: move a test to the right section Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Stefan Beller , Damien Robert , Philippe Blain , Philippe Blain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Philippe Blain The test "$command: submodule branch is not changed, detach HEAD instead" is in the "Appearing submodule" section of test_submodule_recursing_with_args_common(), but this test updates a submodule; it does not test a transition from a state with no submodule to a state with a submodule. As such, for consistency, move it to the "Modified submodule" section of the same function. While at it, add a comment describing the test. Signed-off-by: Philippe Blain --- t/lib-submodule-update.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 5f9eb682f6a..417da3602ae 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -658,22 +658,6 @@ test_submodule_recursing_with_args_common() { test_submodule_content sub1 origin/add_sub1 ) ' - test_expect_success "$command: submodule branch is not changed, detach HEAD instead" ' - prolog && - reset_work_tree_to_interested add_sub1 && - ( - cd submodule_update && - git -C sub1 checkout -b keep_branch && - git -C sub1 rev-parse HEAD >expect && - git branch -t modify_sub1 origin/modify_sub1 && - $command modify_sub1 && - test_superproject_content origin/modify_sub1 && - test_submodule_content sub1 origin/modify_sub1 && - git -C sub1 rev-parse keep_branch >actual && - test_cmp expect actual && - test_must_fail git -C sub1 symbolic-ref HEAD - ) - ' # Replacing a tracked file with a submodule produces a checked out submodule test_expect_success "$command: replace tracked file with submodule checks out submodule" ' @@ -789,6 +773,23 @@ test_submodule_recursing_with_args_common() { test_submodule_content sub1 origin/add_sub1 ) ' + # Updating a submodule does not touch the currently checked out branch in the submodule + test_expect_success "$command: submodule branch is not changed, detach HEAD instead" ' + prolog && + reset_work_tree_to_interested add_sub1 && + ( + cd submodule_update && + git -C sub1 checkout -b keep_branch && + git -C sub1 rev-parse HEAD >expect && + git branch -t modify_sub1 origin/modify_sub1 && + $command modify_sub1 && + test_superproject_content origin/modify_sub1 && + test_submodule_content sub1 origin/modify_sub1 && + git -C sub1 rev-parse keep_branch >actual && + test_cmp expect actual && + test_must_fail git -C sub1 symbolic-ref HEAD + ) + ' } # Declares and invokes several tests that, in various situations, checks that From patchwork Mon Feb 17 04:53:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11385207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12A8017E8 for ; Mon, 17 Feb 2020 04:53:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E746720725 for ; Mon, 17 Feb 2020 04:53:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tbyv2Tp5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727943AbgBQExM (ORCPT ); Sun, 16 Feb 2020 23:53:12 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34331 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727830AbgBQExM (ORCPT ); Sun, 16 Feb 2020 23:53:12 -0500 Received: by mail-wm1-f65.google.com with SMTP id s144so6482445wme.1 for ; Sun, 16 Feb 2020 20:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=mKOGydVWPAfYsYOVWjtxvMBouK6S3P+5Jvfry3Mw2MA=; b=tbyv2Tp5NboaovYG8NCNWTXFN8qH6I4L360VH+RbFxFGjnIZq0AcWPmcQCwMxJLVDN Bymx2vz6pah4rXl9c4zYHxfnm5hSOcvMyZM6C0/xcBkSn3/LcUrMhEHmMK1UqmerFoFO mTCK4HNezzhob3ADBZldGVLgNDOfTfOWApRQZCEn5R8wvhNxKIcuocrYhvhKOcTAteCb f4ITorRDgA2I+yiYuUVxvJ+OHTOM7QuhE4OYjdXjKSONVQ+qzQUwVKtJm+oERceY5j1r bWek5VaHJoJD6cLPpqvTSa4OmGa80nPV1z6cwSYoPgBYPjpfYQXxoM4oNEJ56IQIWIhz 1hEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=mKOGydVWPAfYsYOVWjtxvMBouK6S3P+5Jvfry3Mw2MA=; b=UF+F6pJRzO1f5K6rekSCwpShkpvDTnMIOX1GtEtIc4UuE3aRfaRzGIUMnW9f+Pb0wh /NEMH1ECFx45x+L0uttC41/FLFWHZ8phG2AtE5YIzwTBlsElN1gcVnXQ3diszxRVCMpR 5j+zkSi+/QmFqfPjM0sL4RvRAQFeZgnkore1JuYK13V9XnDP/ePmacE0S8KPgbWG7rA8 ehUCEqG31Wwu7v3plF45nt1mnF+FmFqku1WRUy/TIZx1MIvcM0pj16A/AGsaRsC1y/ja VEBCX/w27xT2qFuBavjdyKfgzXKWPg0+uRIa94CTEVZbUTtWcA/6eKBATChd6W4F+C6k IDyg== X-Gm-Message-State: APjAAAUwbmEfNldXQA/IGejpLXShEsJz8OLSllyAs9Vur0SqMElNoLNc i4FFJpVUv6eJkxPgW6WQ1fVk3L5V X-Google-Smtp-Source: APXvYqxpLgZF1m4AEfoF98rugjBrQwRBbxxWxzKf1quxVGF2Jd5BopxiZPTbiCdt3pmm5CwcIoRIPg== X-Received: by 2002:a1c:791a:: with SMTP id l26mr20032022wme.58.1581915190110; Sun, 16 Feb 2020 20:53:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h18sm18122735wrv.78.2020.02.16.20.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 20:53:09 -0800 (PST) Message-Id: In-Reply-To: References: From: "Philippe Blain via GitGitGadget" Date: Mon, 17 Feb 2020 04:53:04 +0000 Subject: [PATCH 4/6] unpack-trees: remove outdated description for verify_clean_submodule Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Stefan Beller , Damien Robert , Philippe Blain , Philippe Blain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Philippe Blain The function verify_clean_submodule() learned to verify if a submodule working tree is clean in a7bc845a9a (unpack-trees: check if we can perform the operation for submodules, 2017-03-14), but the commented description above it was not updated to reflect that, such that this description has been outdated since then. Since Git has now learned to optionnally recursively check out submodules during a superproject checkout, remove this outdated description. Signed-off-by: Philippe Blain --- unpack-trees.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/unpack-trees.c b/unpack-trees.c index da4d6d4ec01..37eca3ede8b 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1815,9 +1815,6 @@ static void invalidate_ce_path(const struct cache_entry *ce, /* * Check that checking out ce->sha1 in subdir ce->name is not * going to overwrite any working files. - * - * Currently, git does not checkout subprojects during a superproject - * checkout, so it is not going to overwrite anything. */ static int verify_clean_submodule(const char *old_sha1, const struct cache_entry *ce, From patchwork Mon Feb 17 04:53:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11385209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3ABD018E8 for ; Mon, 17 Feb 2020 04:53:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B1D520725 for ; Mon, 17 Feb 2020 04:53:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fOy4jUWv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727976AbgBQExO (ORCPT ); Sun, 16 Feb 2020 23:53:14 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37423 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbgBQExN (ORCPT ); Sun, 16 Feb 2020 23:53:13 -0500 Received: by mail-wr1-f65.google.com with SMTP id w15so17988086wru.4 for ; Sun, 16 Feb 2020 20:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=P1OhgDdMUrX3K1smvSOQJRwn3dz/D8m9Yo3Pa0L7hAY=; b=fOy4jUWv4im/it8qRrIc5MOzNJXdQaEA0Jzqto4OgSSjnoHDBKuE8tspi05KpUNUY7 686e4DKGGY5RODJo/dKbh1FlM9dhKH4b3A0YVhWrvOzag+7bboEFIEvd8583YEDvIaxR a6hQy7GUucbmX3+SDTNepcKEvwcnr2Ytz4ddEw/oNrRV4izJUJ3z0DWgghxNTi4ChbOq JiXNSwwON/rB1t0nuDq/AyiBdmAW3TE+IAYAaPsGeHjT8EktD4pQS0rH8uamZHLYe+Qh 2xaJ2KmKnozOmUchsuF4uKLjimNjbIT4f6XRev7RAGYkCcZh5fgwTluCVrE04/BgwSmJ fvoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=P1OhgDdMUrX3K1smvSOQJRwn3dz/D8m9Yo3Pa0L7hAY=; b=I2ds23Vf8Efwxm0QgYDVIUOqxmFTObS3teZdnpiQdGQD07MqFQa5/5R613oqC4sTEw vmt6Tw40Id563dqRk9jL5s3Cq68326qEO7Q3e0Z487/o9efsKo/exnZImsOcBtnX91TY Jo7AURuTMq4HX5E0buuuHyLU3+Icmo+SdNb3t/W1QSY9AesKK1SG6vmFCuaqPTCsIJEb rgOEiQOBhSAWkSJ6bSS/KNlDge349MfG4tykz90ruVCVdtSJaj4NCfh3QVmMp+M6DxFe 0BYC7BXx5oywKvWPaA3n8ON+0V282tUHe+XoYDcl3+u6028+AsCAlw3u45R5dwYhLV9r OgPQ== X-Gm-Message-State: APjAAAWoxQb8O8nb+r040eMWweftRK4uKDYQNfW1Dv625zQC8uXPiS9A 88dv0/Lv2YYoZvLjCrnPEd3ZFu8P X-Google-Smtp-Source: APXvYqw52sRgS/fgxhGbAUijq3/p6JO0je+QW99GLebplEEGOgfJlq0JlCYSLYaG5xlwHTvqAvNRrg== X-Received: by 2002:adf:e5c4:: with SMTP id a4mr20582190wrn.292.1581915190743; Sun, 16 Feb 2020 20:53:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h2sm19841425wrt.45.2020.02.16.20.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 20:53:10 -0800 (PST) Message-Id: In-Reply-To: References: From: "Philippe Blain via GitGitGadget" Date: Mon, 17 Feb 2020 04:53:05 +0000 Subject: [PATCH 5/6] unpack-trees: check for missing submodule directory in merged_entry Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Stefan Beller , Damien Robert , Philippe Blain , Philippe Blain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Philippe Blain Using `git checkout --recurse-submodules` to switch between a branch with no submodules and a branch with initialized nested submodules currently causes a fatal error: $ git checkout --recurse-submodules branch-with-nested-submodules fatal: exec '--super-prefix=submodule/nested/': cd to 'nested' failed: No such file or directory error: Submodule 'nested' could not be updated. error: Submodule 'submodule/nested' cannot checkout new HEAD. error: Submodule 'submodule' could not be updated. M submodule Switched to branch 'branch-with-nested-submodules' The checkout succeeds but the worktree and index of the first level submodule are left empty: $ cd submodule $ git -c status.submoduleSummary=1 status HEAD detached at b3ce885 Changes to be committed: (use "git restore --staged ..." to unstage) deleted: .gitmodules deleted: first.t deleted: nested fatal: not a git repository: 'nested/.git' Submodule changes to be committed: * nested 1e96f59...0000000: $ git ls-files -s $ # empty $ ls -A .git The reason for the fatal error during the checkout is that a child git process tries to cd into the yet unexisting nested submodule directory. The sequence is the following: 1. The main git process (the one running in the superproject) eventually reaches write_entry() in entry.c, which creates the first level submodule directory and then calls submodule_move_head() in submodule.c, which spawns `git read-tree` in the submodule directory. 2. The first child git process (the one in the submodule of the superproject) eventually calls check_submodule_move_head() at unpack_trees.c:2021, which calls submodule_move_head in dry-run mode, which spawns `git read-tree` in the nested submodule directory. 3. The second child git process tries to chdir() in the yet unexisting nested submodule directory in start_command() at run-command.c:829 and dies before exec'ing. The reason why check_submodule_move_head() is reached in the first child and not in the main process is that it is inside an if(submodule_from_ce()) construct, and submodule_from_ce() returns a valid struct submodule pointer, whereas it returns a null pointer in the main git process. The reason why submodule_from_ce() returns a null pointer in the main git process is because the call to cache_lookup_path() in config_from() (called from submodule_from_path() in submodule_from_ce()) returns a null pointer since the hashmap "for_path" in the submodule_cache of the_repository is not yet populated. It is not populated because both repo_get_oid(repo, GITMODULES_INDEX, &oid) and repo_get_oid(repo, GITMODULES_HEAD, &oid) in config_from_gitmodules() at submodule-config.c:639-640 return -1, as at this stage of the operation, neither the HEAD of the superproject nor its index contain any .gitmodules file. In contrast, in the first child the hashmap is populated because repo_get_oid(repo, GITMODULES_HEAD, &oid) returns 0 as the HEAD of the first level submodule, i.e. .git/modules/submodule/HEAD, points to a commit where .gitmodules is present and records 'nested' as a submodule. Fix this bug by checking that the submodule directory exists before calling check_submodule_move_head() in merged_entry() in the `if(!old)` branch, i.e. if going from a commit with no submodule to a commit with a submodule present. Also protect the other call to check_submodule_move_head() in merged_entry() the same way as it is safer, even though the `else if (!(old->ce_flags & CE_CONFLICTED))` branch of the code is not at play in the present bug. The other calls to check_submodule_move_head() in other functions in unpack_trees.c are all already protected by calls to lstat() somewhere in the program flow so we don't need additional protection for them. All commands in the unpack_trees machinery are affected, i.e. checkout, reset and read-tree when called with the --recurse-submodules flag. This bug was first reported in [1]. [1] https://lore.kernel.org/git/7437BB59-4605-48EC-B05E-E2BDB2D9DABC@gmail.com/ Reported-by: Philippe Blain Reported-by: Damien Robert Signed-off-by: Philippe Blain --- t/lib-submodule-update.sh | 14 ++++++++++++++ unpack-trees.c | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 417da3602ae..ab30b2da24f 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -626,6 +626,7 @@ test_submodule_forced_switch () { # New test cases # - Removing a submodule with a git directory absorbs the submodules # git directory first into the superproject. +# - Switching from no submodule to nested submodules # Internal function; use test_submodule_switch_recursing_with_args() or # test_submodule_forced_switch_recursing_with_args() instead. @@ -683,6 +684,19 @@ test_submodule_recursing_with_args_common() { test_submodule_content sub1 origin/replace_directory_with_sub1 ) ' + # Switching to a commit with nested submodules recursively checks them out + test_expect_success "$command: nested submodules are checked out" ' + prolog && + reset_work_tree_to_interested no_submodule && + ( + cd submodule_update && + git branch -t modify_sub1_recursively origin/modify_sub1_recursively && + $command modify_sub1_recursively && + test_superproject_content origin/modify_sub1_recursively && + test_submodule_content sub1 origin/modify_sub1_recursively && + test_submodule_content -C sub1 sub2 origin/modify_sub1_recursively + ) + ' ######################## Disappearing submodule ####################### # Removing a submodule removes its work tree ... diff --git a/unpack-trees.c b/unpack-trees.c index 37eca3ede8b..fc6ba19486d 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -2064,7 +2064,7 @@ static int merged_entry(const struct cache_entry *ce, } invalidate_ce_path(merge, o); - if (submodule_from_ce(ce)) { + if (submodule_from_ce(ce) && file_exists(ce->name)) { int ret = check_submodule_move_head(ce, NULL, oid_to_hex(&ce->oid), o); @@ -2093,7 +2093,7 @@ static int merged_entry(const struct cache_entry *ce, invalidate_ce_path(old, o); } - if (submodule_from_ce(ce)) { + if (submodule_from_ce(ce) && file_exists(ce->name)) { int ret = check_submodule_move_head(ce, oid_to_hex(&old->oid), oid_to_hex(&ce->oid), o); From patchwork Mon Feb 17 04:53:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11385215 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4534518E8 for ; Mon, 17 Feb 2020 04:53:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 263F920725 for ; Mon, 17 Feb 2020 04:53:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OEmsIH1w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbgBQExR (ORCPT ); Sun, 16 Feb 2020 23:53:17 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35427 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbgBQExN (ORCPT ); Sun, 16 Feb 2020 23:53:13 -0500 Received: by mail-wr1-f66.google.com with SMTP id w12so17983889wrt.2 for ; Sun, 16 Feb 2020 20:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=fNHHYop37NoayjUMF4vkw/ZhMKFfXENYfUyVkavDQhE=; b=OEmsIH1w94mSFBE2jzKNNJ6ethd8dzx3qDoSeGxKLQeJm/kC1hiRllXwYyEFy4hW4U 4QwL0VRFjk8LqcnA01RPXbWTtoMUXyObJWhK5XOZcdwGR9htCHmr6QvMaiSle4akFeeo h4ARCOH2BL4Sm70HWnr5a435enp657x0sF7xiHTB5paHfm3Slbs8HJgPPRvWb5pyVcAS LCDlIeVrfoQUt6YW9HhVfZsQhrPk60BLjDo7jdlRj2FYqUFBOjekJq+9tqdO7wQFIViC TKAm7iKkCbuOLb18ZRGm8sXSe2tlXMM9w/W2SvCmmk9hDuY5IalVmmtbaL+jE/T/rXYt PXIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=fNHHYop37NoayjUMF4vkw/ZhMKFfXENYfUyVkavDQhE=; b=tc30zFcfv0RgO2GPDO4hYSQxkpkISuLE31xG9sw4Ewwj/rLlH1LgKZ5LQ0ZwwrSTyW kcmie08jWgZverJ6pJzkyw9CdbxCQT8ZR3HBguECCQ+KgTXUjAmiBKq0tAFc2grhZbFO jjUTtbl3gYzQOWv2kYKDI7/w+EX1Vg1kmxN2OZERYJSH/Qu8vGmx3SA5cTTl1gkeP7z4 uoBgZozkkUfqZNMkIAqGwOej3+9doPeSkuy3jPJdDLotCWVEZiMk2v6Fdslf5FkN/jKQ kyz+obb0DO64YqKZbrdUtNWvi9EEv4DqljQlo0kSgc4MiTD7WuF6IoYlKimaNUc/sgSe DQXA== X-Gm-Message-State: APjAAAXEalqvAgAbT38glQYzdysWhg1GhIR/pCyz+Y5Q+Q2V08GVAaiC gaUYTP8kJE/gBKdBvX2sMOKvx1is X-Google-Smtp-Source: APXvYqy95ECmrSy3X4AAlD8kIBsUNG7T8zSS/ZxBAKQHmxab164ceIJ+4sxnPKCy2ieqx9wcZqmHug== X-Received: by 2002:adf:a285:: with SMTP id s5mr20560877wra.118.1581915191523; Sun, 16 Feb 2020 20:53:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m3sm19751836wrs.53.2020.02.16.20.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 20:53:11 -0800 (PST) Message-Id: <70b2a20b4ebb09ccb85b576c212075ab1ca75601.1581915186.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Philippe Blain via GitGitGadget" Date: Mon, 17 Feb 2020 04:53:06 +0000 Subject: [PATCH 6/6] t/lib-submodule-update: add test removing nested submodules Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Stefan Beller , Damien Robert , Philippe Blain , Philippe Blain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Philippe Blain The previous commit fixed a bug with the (no submodule) -> (nested submodules) transition for commands in the unpack-trees machinery. Let's add a test for the reverse transition (going from nested submodules to no submodule), as it is not being tested currently. While at it, uniformize the capitalization in the list of tests. Signed-off-by: Philippe Blain --- t/lib-submodule-update.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index ab30b2da24f..64fc6487dd9 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -297,7 +297,7 @@ test_submodule_content () { # - Directory containing tracked files replaced by submodule # - Submodule replaced by tracked files in directory # - Submodule replaced by tracked file with the same name -# - tracked file replaced by submodule +# - Tracked file replaced by submodule # # The default is that submodule contents aren't changed until "git submodule # update" is run. And even then that command doesn't delete the work tree of @@ -621,12 +621,13 @@ test_submodule_forced_switch () { # - Directory containing tracked files replaced by submodule # - Submodule replaced by tracked files in directory # - Submodule replaced by tracked file with the same name -# - tracked file replaced by submodule +# - Tracked file replaced by submodule # # New test cases # - Removing a submodule with a git directory absorbs the submodules # git directory first into the superproject. # - Switching from no submodule to nested submodules +# - Switching from nested submodules to no submodule # Internal function; use test_submodule_switch_recursing_with_args() or # test_submodule_forced_switch_recursing_with_args() instead. @@ -760,6 +761,21 @@ test_submodule_recursing_with_args_common() { ) ' + # Switching to a commit without nested submodules removes their worktrees + test_expect_success "$command: worktrees of nested submodules are removed" ' + prolog && + reset_work_tree_to_interested add_nested_sub && + ( + cd submodule_update && + git branch -t no_submodule origin/no_submodule && + $command no_submodule && + test_superproject_content origin/no_submodule && + ! test_path_is_dir sub1 && + test_must_fail git config -f .git/modules/sub1/config core.worktree && + test_must_fail git config -f .git/modules/sub1/modules/sub2/config core.worktree + ) + ' + ########################## Modified submodule ######################### # Updating a submodule sha1 updates the submodule's work tree test_expect_success "$command: modified submodule updates submodule work tree" '