From patchwork Thu Aug 26 20:59:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 12460667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A184C4320E for ; Thu, 26 Aug 2021 21:00:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE6496103A for ; Thu, 26 Aug 2021 21:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243606AbhHZVBD (ORCPT ); Thu, 26 Aug 2021 17:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243597AbhHZVBC (ORCPT ); Thu, 26 Aug 2021 17:01:02 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D152EC0613C1 for ; Thu, 26 Aug 2021 14:00:14 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id u14so9054253ejf.13 for ; Thu, 26 Aug 2021 14:00:14 -0700 (PDT) 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=psUg+hL3CydiurDd5kHZxqXmzehbIRKXtj0b29Ft2ig=; b=iWpmLhyXIS4XXJ1b0ENyjdWwXP3mBPqQMQYGUIL9D34eqwGjpE3BWesYHVe//W7ikp mcfK/rihzCde24/9QcX5XcC5Jyyvbvm7EWJp+NIVMI6YRTsIYmZV8Qi1W+nEg+AU5Vai lypdwm7wUBIzj/N1opT2gTe+GpmNvhaUyEKRLiVixMCmCDP2vFBpWRcE/X4Yq8OrucLN NDhyA87tai89tBuBwaSTY1BMC0OAYJC9fnncW5fZkIF+aDDCSvTLpq/kVrm/B22osK97 uLhzo5kieu5zXBxpx5iDDemiMAiC7cL+E3K1dVRLnTiR7NT0gVauPmYM0/i8RgcjW3Nw WXag== 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=psUg+hL3CydiurDd5kHZxqXmzehbIRKXtj0b29Ft2ig=; b=dyuwBILZbnNJ7JLKs2iMuwrca/RDlqeATo2b/9nm0vOUM7Md4fmmbPJCTwqet6A0ak z98BMdFgpDaeuX//I7brMcJHCIhVd5yIN80Mf8rQnAvAKm7KvTMo9b4B2JCFeZId5V+y MAWqGxHIsgAdHxM4AKziP+lcntAjyjz8+XMnrUdFxxmkxGLl7wv0iNsZTli5muCvWshc btTBsTvpylGuYnym1s/HLQHx2y9vCSLbZ0vEQAG5YpsiwHuc/rFZjf3QBKGp+1tQgUKf gWGQ9Y7gUAW41sw6cp+N5mUJXxbEjuPNocI2mfojfGcUOOj6RjtjWmr+sIhQ/ymQIUfe we8g== X-Gm-Message-State: AOAM531QBz0bdZEFTf/z4Pgbqp0Qn+77gHwxmkGGANOsr+vbyEPR0NyH QsjiJzZMsogdtSO/OwBDxGrTRrb80eA= X-Google-Smtp-Source: ABdhPJwzlIT+9b1b2flAJdRSfnxQu78a08c9TWGHkz/e1Tv+t5MkqrBFNEV3gNNJ013clunU6lAAzg== X-Received: by 2002:a17:906:9b87:: with SMTP id dd7mr5965796ejc.99.1630011613470; Thu, 26 Aug 2021 14:00:13 -0700 (PDT) Received: from localhost.localdomain (84-236-78-211.pool.digikabel.hu. [84.236.78.211]) by smtp.gmail.com with ESMTPSA id q14sm1884779ejc.93.2021.08.26.14.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:00:13 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Derrick Stolee , Thomas Gummerer , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 1/6] t1600-index: remove unnecessary redirection Date: Thu, 26 Aug 2021 22:59:59 +0200 Message-Id: <20210826210004.672860-2-szeder.dev@gmail.com> X-Mailer: git-send-email 2.33.0.358.g803110d36e In-Reply-To: <20210826210004.672860-1-szeder.dev@gmail.com> References: <20210817174938.3009923-1-szeder.dev@gmail.com> <20210826210004.672860-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a helper function in the 't1600-index.sh' test script the stderr of a 'git add' command is redirected to its stdout, but its stdout is not redirected anywhere. So apparently this redirection is unnecessary, remove it. Signed-off-by: SZEDER Gábor --- t/t1600-index.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t1600-index.sh b/t/t1600-index.sh index c9b9e718b8..5d10cec67a 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -79,7 +79,7 @@ test_index_version () { else unset GIT_INDEX_VERSION fi && - git add a 2>&1 && + git add a && echo $EXPECTED_OUTPUT_VERSION >expect && test-tool index-version <.git/index >actual && test_cmp expect actual From patchwork Thu Aug 26 21:00:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 12460669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AF55C43214 for ; Thu, 26 Aug 2021 21:00:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E7B66103C for ; Thu, 26 Aug 2021 21:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243615AbhHZVBE (ORCPT ); Thu, 26 Aug 2021 17:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243603AbhHZVBD (ORCPT ); Thu, 26 Aug 2021 17:01:03 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D418C061757 for ; Thu, 26 Aug 2021 14:00:15 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id n11so6610689edv.11 for ; Thu, 26 Aug 2021 14:00:15 -0700 (PDT) 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=QdR1aQKjlpEG5QSHNUMLX+QG8NVn1igfaNppAefxTmM=; b=jNEUjP+2M4GdvdksgtuU2ueAhaKBiKO7KJ48Voxrdofa9csadpCWKMpvlWvkn/q/kl kYsoJQ812PflibGyE5Tzy6iGVsfq9GqdFFUq11b7TSOaE1JJiwABcjKJPuRg4pBZMm5W V/ErLh/me2hIhMRJ4VsbL1kVH9Auf0zgk+Q/r2/pHLr9mC50VEoqBcDa7INHPf51EHkr Mjix1l8eE86j0sdQxcN8RVH/XKTr9fXQT2eO6yxJJzlwUsY+V9cgEZbdGb3JM/Kj1C6m OOjF153bBZUUiz2/o8XdUzfHwoJo5nH4uELyWpusfMTr7eamj0UIg1hiEtds4UvaGmQN knRQ== 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=QdR1aQKjlpEG5QSHNUMLX+QG8NVn1igfaNppAefxTmM=; b=Flow3XA7rnV8JZ/NLE8kPUU7PbHfpvUKFXt1KllNuZtVb1WplLpGkK5wy4OZbzozsg Vo73v1re+3m6IE5mRv2yJvb/xYFq3gchZXG4unWYUXV8luEAhfrR4D/iOlStA76hxiv4 38ZEcq42IpYqqAsXOLeu2cNf5ea9Pn/CEoHsgHJcSK6SVPnVKMVbMDmQA20ufIMli1n4 ncUBj3II3dkWDCT+i3gZCq2F6SuMp5wPryxOwNZN6YizGMGRh7ng9r1+NDHEKTLw7be4 CwcLtasq+m2H1QFcb1/m+HSwElaUVVuPrt5r70JqzyYJddIREEiu5X2IGWjeBsBzW7sl 6d6A== X-Gm-Message-State: AOAM531za2yBMSoyasS5Tgo2OLE/DjP4zFlmSl0GukpqN+DDumSw5rtl 6HwvmFjpIhRbgqoX2b7k+774/h5ZHlY= X-Google-Smtp-Source: ABdhPJyN6IefuyBQ8k9RXkkMewrkLIrm0wF1/hP9b/Dq/uz1JoyCy4btATKCaRldU61c1BJ2/00RbQ== X-Received: by 2002:aa7:d455:: with SMTP id q21mr1416023edr.5.1630011614128; Thu, 26 Aug 2021 14:00:14 -0700 (PDT) Received: from localhost.localdomain (84-236-78-211.pool.digikabel.hu. [84.236.78.211]) by smtp.gmail.com with ESMTPSA id q14sm1884779ejc.93.2021.08.26.14.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:00:13 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Derrick Stolee , Thomas Gummerer , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 2/6] t1600-index: don't run git commands upstream of a pipe Date: Thu, 26 Aug 2021 23:00:00 +0200 Message-Id: <20210826210004.672860-3-szeder.dev@gmail.com> X-Mailer: git-send-email 2.33.0.358.g803110d36e In-Reply-To: <20210826210004.672860-1-szeder.dev@gmail.com> References: <20210817174938.3009923-1-szeder.dev@gmail.com> <20210826210004.672860-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: SZEDER Gábor --- t/t1600-index.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/t/t1600-index.sh b/t/t1600-index.sh index 5d10cec67a..aa88fc30ce 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -13,7 +13,8 @@ test_expect_success 'bogus GIT_INDEX_VERSION issues warning' ' rm -f .git/index && GIT_INDEX_VERSION=2bogus && export GIT_INDEX_VERSION && - git add a 2>&1 | sed "s/[0-9]//" >actual.err && + git add a 2>err && + sed "s/[0-9]//" err >actual.err && sed -e "s/ Z$/ /" <<-\EOF >expect.err && warning: GIT_INDEX_VERSION set, but the value is invalid. Using version Z @@ -27,7 +28,8 @@ test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' ' rm -f .git/index && GIT_INDEX_VERSION=1 && export GIT_INDEX_VERSION && - git add a 2>&1 | sed "s/[0-9]//" >actual.err && + git add a 2>err && + sed "s/[0-9]//" err >actual.err && sed -e "s/ Z$/ /" <<-\EOF >expect.err && warning: GIT_INDEX_VERSION set, but the value is invalid. Using version Z @@ -50,7 +52,8 @@ test_expect_success 'out of bounds index.version issues warning' ' sane_unset GIT_INDEX_VERSION && rm -f .git/index && git config --add index.version 1 && - git add a 2>&1 | sed "s/[0-9]//" >actual.err && + git add a 2>err && + sed "s/[0-9]//" err >actual.err && sed -e "s/ Z$/ /" <<-\EOF >expect.err && warning: index.version set, but the value is invalid. Using version Z From patchwork Thu Aug 26 21:00:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 12460671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E5B4C432BE for ; Thu, 26 Aug 2021 21:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46D926103A for ; Thu, 26 Aug 2021 21:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243616AbhHZVBH (ORCPT ); Thu, 26 Aug 2021 17:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243612AbhHZVBE (ORCPT ); Thu, 26 Aug 2021 17:01:04 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219DCC061757 for ; Thu, 26 Aug 2021 14:00:16 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id mf2so9106043ejb.9 for ; Thu, 26 Aug 2021 14:00:16 -0700 (PDT) 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=t55I09QR54J0prUQgQGz8Y/0+6hYR7ofIGx06kmBclI=; b=l38jHcHTPuzjGzu+0KQ4lK91BFl1ovRGXeHcDgQlJ/QoixsOv7d5XJlnLPCfmj+TKE XINdnC+1RIwN76Nx2NMs8l+8CxMo7WlRW+Lses+YT1905Ax5uqAond0+DY5SMj0bzMUt S6N+9Cuxt+LZxXVnoO9KHu+YNEgZdbUXPUdomwgJsgZd5ByrJ2j+usM1Itr2r8qCAbMS /rrh+OU1z06x3MB+6xnnY3YRuxb9YDacm3J0gwGzKAwbD/DBNopgk1UxYsKg5aBN/xPI xRG8qEo1+np6N4BlkqRGT8uoEYSYYqgwaTaC0YqdL30FSQRmL6ny3TJ0bFGuqwrcMpQX RuSQ== 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=t55I09QR54J0prUQgQGz8Y/0+6hYR7ofIGx06kmBclI=; b=VTyLTetRz1YmDIJfHMX4DR1uW2Xy8110Q/LZO+198ozqXUCahrfwYaFOAHFa/7CAln QJuz/6wRH++Gl+3V82/88Cvz8uZZgpfhapoQW9Za/BGtqyVg6N11hCn6dzxLVqN/IAL3 AjPFiYldkiwyCZoB6B2EAD2Tt78rgrUr6OHyFJcVMMCo8DlMk8m/GFaNuUsBqXDJtF8b 4Wkji5axm8AZnueuxXWjE0UFRXrq8bmOSzrjP1g+VC4yO40L8vgXKcklqt/Sf6EXyJEO xGiJ25oxoY8DmEhrK/+pVlD9qNfagb7AzGziNKiIQoPsaFDdV1WrbBtm/8kftf3ei15/ np0w== X-Gm-Message-State: AOAM531iL0SRviMmwc4CcYwJHwxHpDLGjEva1RtlCP90Xi5p/b1ZO4Kd ddg3FiH/JtTcZ3Wl9plrQqxott4Fc5g= X-Google-Smtp-Source: ABdhPJxgARRKWYID5PLzZ42RjGD/ZuAYPmL8hNPAB/js1bEqu7PBUbLMSvk1hX+utDg8ZDwSplhcDA== X-Received: by 2002:a17:906:5f93:: with SMTP id a19mr6489106eju.126.1630011614667; Thu, 26 Aug 2021 14:00:14 -0700 (PDT) Received: from localhost.localdomain (84-236-78-211.pool.digikabel.hu. [84.236.78.211]) by smtp.gmail.com with ESMTPSA id q14sm1884779ejc.93.2021.08.26.14.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:00:14 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Derrick Stolee , Thomas Gummerer , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 3/6] t1600-index: disable GIT_TEST_SPLIT_INDEX Date: Thu, 26 Aug 2021 23:00:01 +0200 Message-Id: <20210826210004.672860-4-szeder.dev@gmail.com> X-Mailer: git-send-email 2.33.0.358.g803110d36e In-Reply-To: <20210826210004.672860-1-szeder.dev@gmail.com> References: <20210817174938.3009923-1-szeder.dev@gmail.com> <20210826210004.672860-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Tests in 't1600-index.sh' check that various bogus index version values are recognized and an appropriate warning message is issued. GIT_TEST_SPLIT_INDEX=1 is supposed to trigger index splitting randomly, and thus might interfere [1] with these tests: splitting the index means that two index files are written (the shared base index and the split '.git/index'), and the same warning message is then issued twice, failing these tests. Unset GIT_TEST_SPLIT_INDEX in this test script to avoid such interference. [1] There is no such interference at the moment, because, alas, GIT_TEST_SPLIT_INDEX=1 is broken and never split the index. There was no such interference in the past (before it broke) either, because the first index write with GIT_TEST_SPLIT_INDEX=1 never split the index, only the second write did. A subsequent commit fixing GIT_TEST_SPLIT_INDEX will have all the details on this. Signed-off-by: SZEDER Gábor --- t/t1600-index.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/t1600-index.sh b/t/t1600-index.sh index aa88fc30ce..46329c488b 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -4,6 +4,8 @@ test_description='index file specific tests' . ./test-lib.sh +sane_unset GIT_TEST_SPLIT_INDEX + test_expect_success 'setup' ' echo 1 >a ' From patchwork Thu Aug 26 21:00:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 12460673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ACAFC4320E for ; Thu, 26 Aug 2021 21:00:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 551D760EE5 for ; Thu, 26 Aug 2021 21:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243626AbhHZVBH (ORCPT ); Thu, 26 Aug 2021 17:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243614AbhHZVBE (ORCPT ); Thu, 26 Aug 2021 17:01:04 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCCABC0613C1 for ; Thu, 26 Aug 2021 14:00:16 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id b7so6658778edu.3 for ; Thu, 26 Aug 2021 14:00:16 -0700 (PDT) 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=VRGE+vejbJYxOysILJDGLQN8MZpRmXDaO3vCDFqWDZY=; b=bJ+n3unQxl1nDdqK5qif35iEyFiq8rIdtLZn8BC4c1qpyK0Sn+K4hTo61FyvfSgFtK lYGvAeNuWXk+J0IGWt5i/bU77xdgQ1AZF920dobzR6QoV4cQDepyGzmvPofwuS5oG36h hUDhlu5NhCNcuILScMu2B+hj0OgjtwqK/qTnjI9UGO8TK6Dw0h5VAAbeZ19Oiw2FMgxx q6dQUjXUiAeq43eBicLoXgb3oEul86PFM7exYGCEtCI0NQLhcvPf07GKHMbUd3fPAy2t jAd9z7xAgWi+4TynFJUrbHf/2vOWV9+pk5lvK96zdl2hGKLBTIjMwjndgV87V5XF0RKZ TVIQ== 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=VRGE+vejbJYxOysILJDGLQN8MZpRmXDaO3vCDFqWDZY=; b=cUZokwb8SmBUO0Ob03qH7SPLMM2PChl4q1TweXstAOXwmUeLVp6ByURD/kvFWsP3GK 1CCSWWrTkaHETI8qwzSUWAjUnY7MLOuTG4hHncs/As9zRDwl7tHXUJkGAHpr/qrmjMCG eJeZixEoBO9822IDJF51S/r7IZSpyNzg9Xsh0nA+zy1VN+n8tTQEBwmuCi3Ec119CCuL VEA8evgdbPh+Rtbofu9qibdvpzLZC/nxp9FdtwZjiyc/m221Wm1Sb7HcKBtkEjnpBW8f cF/6gVCmy9DkBQnBw7tDTfCjzLvb2Lb4YhdqK/1k6iPeQ95eO95hAf54v39BejmLZf3w 1v7A== X-Gm-Message-State: AOAM5328pEy1NEEbwjMiP/QlVummOpfEntFuAHafG+nWst5guYLYg9NQ HWsNW790rb6PLjI9O5T4NAoRqIsCxDQ= X-Google-Smtp-Source: ABdhPJzE6dFdlFwVO9EWm2Fr3FNq6eaMbYpYhXpgl8UPl1kbz6Dz7weVu8bpaSaHUxTv0rW4YVM1iQ== X-Received: by 2002:aa7:d6d1:: with SMTP id x17mr6345497edr.64.1630011615302; Thu, 26 Aug 2021 14:00:15 -0700 (PDT) Received: from localhost.localdomain (84-236-78-211.pool.digikabel.hu. [84.236.78.211]) by smtp.gmail.com with ESMTPSA id q14sm1884779ejc.93.2021.08.26.14.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:00:15 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Derrick Stolee , Thomas Gummerer , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 4/6] read-cache: look for shared index files next to the index, too Date: Thu, 26 Aug 2021 23:00:02 +0200 Message-Id: <20210826210004.672860-5-szeder.dev@gmail.com> X-Mailer: git-send-email 2.33.0.358.g803110d36e In-Reply-To: <20210826210004.672860-1-szeder.dev@gmail.com> References: <20210817174938.3009923-1-szeder.dev@gmail.com> <20210826210004.672860-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When reading a split index git always looks for its referenced shared base index in the gitdir of the current repository, even when reading an alternate index specified via GIT_INDEX_FILE, and even when that alternate index file is the "main" '.git/index' file of an other repository. However, if that split index and its referenced shared index files were written by a git command running entirely in that other repository, then, naturally, the shared index file is written to that other repository's gitdir. Consequently, a git command attempting to read that shared index file while running in a different repository won't be able find it and will error out. I'm not sure in what use case it is necessary to read the index of one repository by a git command running in a different repository, but it is certainly possible to do so, and in fact the test 'bare repository: check that --cached honors index' in 't0003-attributes.sh' does exactly that. If GIT_TEST_SPLIT_INDEX=1 were to split the index in just the right moment [1], then this test would indeed fail, because the referenced shared index file could not be found. Let's look for the referenced shared index file not only in the gitdir of the current directory, but, if the shared index is not there, right next to the split index as well. [1] We haven't seen this issue trigger a failure in t0003 yet, because: - While GIT_TEST_SPLIT_INDEX=1 is supposed to trigger index splitting randomly, the first index write has always been deterministic and it has never split the index. - That alternate index file in the other repository is written only once in the entire test script, so it's never split. However, the next patch will fix GIT_TEST_SPLIT_INDEX, and while doing so it will slightly change its behavior to always split the index already on the first index write, and t0003 would always fail without this patch. Signed-off-by: SZEDER Gábor --- read-cache.c | 14 +++++++++++++- t/t1700-split-index.sh | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/read-cache.c b/read-cache.c index 9048ef9e90..fbd59886a3 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2391,9 +2391,21 @@ int read_index_from(struct index_state *istate, const char *path, base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex); trace2_region_enter_printf("index", "shared/do_read_index", the_repository, "%s", base_path); - ret = do_read_index(split_index->base, base_path, 1); + ret = do_read_index(split_index->base, base_path, 0); trace2_region_leave_printf("index", "shared/do_read_index", the_repository, "%s", base_path); + if (!ret) { + char *path_copy = xstrdup(path); + const char *base_path2 = xstrfmt("%s/sharedindex.%s", + dirname(path_copy), + base_oid_hex); + free(path_copy); + trace2_region_enter_printf("index", "shared/do_read_index", + the_repository, "%s", base_path2); + ret = do_read_index(split_index->base, base_path2, 1); + trace2_region_leave_printf("index", "shared/do_read_index", + the_repository, "%s", base_path2); + } if (!oideq(&split_index->base_oid, &split_index->base->oid)) die(_("broken index, expect %s in %s, got %s"), base_oid_hex, base_path, diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index 986baa612e..e2aa0bd949 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -510,4 +510,27 @@ test_expect_success 'do not refresh null base index' ' ) ' +test_expect_success 'reading split index at alternate location' ' + git init reading-alternate-location && + ( + cd reading-alternate-location && + >file-in-alternate && + git update-index --split-index --add file-in-alternate + ) && + echo file-in-alternate >expect && + + # Should be able to find the shared index both right next to + # the specified split index file ... + GIT_INDEX_FILE=./reading-alternate-location/.git/index \ + git ls-files --cached >actual && + test_cmp expect actual && + + # ... and, for backwards compatibility, in the current GIT_DIR + # as well. + mv -v ./reading-alternate-location/.git/sharedindex.* .git && + GIT_INDEX_FILE=./reading-alternate-location/.git/index \ + git ls-files --cached >actual && + test_cmp expect actual +' + test_done From patchwork Thu Aug 26 21:00:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 12460677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CDFAC4320A for ; Thu, 26 Aug 2021 21:00:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 169F161037 for ; Thu, 26 Aug 2021 21:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243636AbhHZVBJ (ORCPT ); Thu, 26 Aug 2021 17:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243603AbhHZVBF (ORCPT ); Thu, 26 Aug 2021 17:01:05 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AA5C0613CF for ; Thu, 26 Aug 2021 14:00:17 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id h9so9159841ejs.4 for ; Thu, 26 Aug 2021 14:00:17 -0700 (PDT) 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=VzZKFUquloWLkACgCZyMkexVIJp5DtToCFEqde8R7+M=; b=YfVTceMDM6WzOOKSrgqb4OY13WClkHRZQLWsLPCatn1anNw+opMK6kyhRrrvePXqSk EmYMI7jEWZLT1oLU/ylv9IIND2GhKFu/gBFs6XFyM6ATozFZcDfH6zVGSUME7C17ESeU bMkwwT/7geTkIlhDesOJ2SCb39gZ26zY5oEuOyo6dwlpFaDIINXUfG7iCFpPboeATXlO 7AfeQfsZ/Lv4KdhPeQA2lATCjUDGabOgZzjDDSWQxU0iglDj9Ag3Iqko1gEnXP0hLYRb zuBd1NZbq62FXnyaRW+x1aMppP5txgcj2os9uNkrK65gRQHiii7bg+IZ/L5u84U6EX7E GRew== 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=VzZKFUquloWLkACgCZyMkexVIJp5DtToCFEqde8R7+M=; b=NTWd0Ym+UOgHf3/UxDHTKtmnXyHERjfsH9UgFzgrcHjeQdEJHsxnamR98TQVfivmpz GbTOvrPmMapyF4GzA0JvHA5grzOarlRCrvIaPaIFAjWENkj00YpqARfsgrt+fG/AFKfz /pbWm/T6OvaN9PjVW43gsIiSduOcmL67y/L5Ku+V2AosCHPIQAlpCqDx76VoCRfFyRE2 Q2pYq4MNgOmL9qUuj6LvKvj5+h80upOl6juo1fU4J5lLZRiI82C/0Ip/R1DOak/XPjft hXIHLT02HIVIFCX5MX8f84AGZ0uVLOk0SjwKIjm5x2Q5NJNOj3PJdQakAPFHRvFV0wyp RMXw== X-Gm-Message-State: AOAM532oKVhJGtWmIU7XF+GhR6XeFqz8CDVG3qpJtkC+xShUYAHKPFc3 ZU0NxHV6vLtVITinGnkFdFHP6EYFqmI= X-Google-Smtp-Source: ABdhPJzSP0o0Kr5ZUmHmqnp3P6O/s6L4aR2JoXWjlW2Z8JYeFEo3AHaOWhRUMg4MtDAhkVWiPOHYDw== X-Received: by 2002:a17:907:9908:: with SMTP id ka8mr6261557ejc.164.1630011615974; Thu, 26 Aug 2021 14:00:15 -0700 (PDT) Received: from localhost.localdomain (84-236-78-211.pool.digikabel.hu. [84.236.78.211]) by smtp.gmail.com with ESMTPSA id q14sm1884779ejc.93.2021.08.26.14.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:00:15 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Derrick Stolee , Thomas Gummerer , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 5/6] tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests Date: Thu, 26 Aug 2021 23:00:03 +0200 Message-Id: <20210826210004.672860-6-szeder.dev@gmail.com> X-Mailer: git-send-email 2.33.0.358.g803110d36e In-Reply-To: <20210826210004.672860-1-szeder.dev@gmail.com> References: <20210817174938.3009923-1-szeder.dev@gmail.com> <20210826210004.672860-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The sparse index and split index features are said to be currently incompatible [1], and consequently GIT_TEST_SPLIT_INDEX=1 might interfere with the test cases exercising the sparse index feature. Therefore GIT_TEST_SPLIT_INDEX is already explicitly disabled for the whole of 't1092-sparse-checkout-compatibility.sh'. There are, however, two other test cases exercising sparse index, namely 'sparse-index enabled and disabled' in 't1091-sparse-checkout-builtin.sh' and 'status succeeds with sparse index' in 't7519-status-fsmonitor.sh', and these two could fail with GIT_TEST_SPLIT_INDEX=1 as well [2]. Unset GIT_TEST_SPLIT_INDEX and disable the split index in these two test cases to avoid such interference. Note that this is the minimal change to merely avoid failures when these test cases are run with GIT_TEST_SPLIT_INDEX=1. Interestingly, though, without these changes the 'git sparse-checkout init --cone --sparse-index' commands still succeed even with split index, and set all the necessary configuration variables and create the initial '$GIT_DIR/info/sparse-checkout' file, but the test failures are caused by later sanity checks finding that the index is not in fact a sparse index. This indicates that 'git sparse-checkout init --sparse-index' lacks some error checking and its tests lack coverage related to split index, but fixing those issues is beyond the scope of this patch series. [1] https://public-inbox.org/git/48e9c3d6-407a-1843-2d91-22112410e3f8@gmail.com/ [2] Neither of these test cases fail at the moment, because GIT_TEST_SPLIT_INDEX=1 is broken and never splits the index, and it broke long before the sparse index feature was added. This patch series is about to fix GIT_TEST_SPLIT_INDEX, and then both test cases mentioned above would fail. (The diff is best viewed with '--ignore-all-space') Signed-off-by: SZEDER Gábor --- t/t1091-sparse-checkout-builtin.sh | 25 ++++++----- t/t7519-status-fsmonitor.sh | 68 ++++++++++++++++-------------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index 38fc8340f5..3f94c41241 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -206,16 +206,21 @@ test_expect_success 'sparse-checkout disable' ' ' test_expect_success 'sparse-index enabled and disabled' ' - git -C repo sparse-checkout init --cone --sparse-index && - test_cmp_config -C repo true index.sparse && - test-tool -C repo read-cache --table >cache && - grep " tree " cache && - - git -C repo sparse-checkout disable && - test-tool -C repo read-cache --table >cache && - ! grep " tree " cache && - git -C repo config --list >config && - ! grep index.sparse config + ( + sane_unset GIT_TEST_SPLIT_INDEX && + git -C repo update-index --no-split-index && + + git -C repo sparse-checkout init --cone --sparse-index && + test_cmp_config -C repo true index.sparse && + test-tool -C repo read-cache --table >cache && + grep " tree " cache && + + git -C repo sparse-checkout disable && + test-tool -C repo read-cache --table >cache && + ! grep " tree " cache && + git -C repo config --list >config && + ! grep index.sparse config + ) ' test_expect_success 'cone mode: init and set' ' diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 6f2cf306f6..451734b9c2 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -399,41 +399,45 @@ check_sparse_index_behavior () { } test_expect_success 'status succeeds with sparse index' ' - git clone . full && - git clone . sparse && - git -C sparse sparse-checkout init --cone --sparse-index && - git -C sparse sparse-checkout set dir1 dir2 && + ( + sane_unset GIT_TEST_SPLIT_INDEX && - write_script .git/hooks/fsmonitor-test <<-\EOF && - printf "last_update_token\0" - EOF - git -C full config core.fsmonitor ../.git/hooks/fsmonitor-test && - git -C sparse config core.fsmonitor ../.git/hooks/fsmonitor-test && - check_sparse_index_behavior ! && + git clone . full && + git clone . sparse && + git -C sparse sparse-checkout init --cone --sparse-index && + git -C sparse sparse-checkout set dir1 dir2 && - write_script .git/hooks/fsmonitor-test <<-\EOF && - printf "last_update_token\0" - printf "dir1/modified\0" - EOF - check_sparse_index_behavior ! && - - git -C sparse sparse-checkout add dir1a && + write_script .git/hooks/fsmonitor-test <<-\EOF && + printf "last_update_token\0" + EOF + git -C full config core.fsmonitor ../.git/hooks/fsmonitor-test && + git -C sparse config core.fsmonitor ../.git/hooks/fsmonitor-test && + check_sparse_index_behavior ! && - for repo in full sparse - do - cp -r $repo/dir1 $repo/dir1a && - git -C $repo add dir1a && - git -C $repo commit -m "add dir1a" || return 1 - done && - git -C sparse sparse-checkout set dir1 dir2 && - - # This one modifies outside the sparse-checkout definition - # and hence we expect to expand the sparse-index. - write_script .git/hooks/fsmonitor-test <<-\EOF && - printf "last_update_token\0" - printf "dir1a/modified\0" - EOF - check_sparse_index_behavior + write_script .git/hooks/fsmonitor-test <<-\EOF && + printf "last_update_token\0" + printf "dir1/modified\0" + EOF + check_sparse_index_behavior ! && + + git -C sparse sparse-checkout add dir1a && + + for repo in full sparse + do + cp -r $repo/dir1 $repo/dir1a && + git -C $repo add dir1a && + git -C $repo commit -m "add dir1a" || return 1 + done && + git -C sparse sparse-checkout set dir1 dir2 && + + # This one modifies outside the sparse-checkout definition + # and hence we expect to expand the sparse-index. + write_script .git/hooks/fsmonitor-test <<-\EOF && + printf "last_update_token\0" + printf "dir1a/modified\0" + EOF + check_sparse_index_behavior + ) ' test_done From patchwork Thu Aug 26 21:00:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 12460675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EBA4C43214 for ; Thu, 26 Aug 2021 21:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25DB46103A for ; Thu, 26 Aug 2021 21:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243632AbhHZVBJ (ORCPT ); Thu, 26 Aug 2021 17:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243620AbhHZVBG (ORCPT ); Thu, 26 Aug 2021 17:01:06 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E021C0613D9 for ; Thu, 26 Aug 2021 14:00:18 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id t19so9108134ejr.8 for ; Thu, 26 Aug 2021 14:00:18 -0700 (PDT) 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=RfCMCXrYA1B7hdl4+HTn56eOFcFdIZ1MngaEqknT0CQ=; b=Xl72Yk3lVec8z0Hsq4INtfoAkA+fZWtvt5aqgomJkJXQULYGO5uMvveeGRpd7Mqytc o2c58OfMIcfGcLR1tLmDJ9j3Q08pGvzHHQOjrXGy38lMt/EKbvEKwaAxql5bXpoTeXpd 6BR3NmOa00UvR9QPZ+rnPK66oD33xChngMPPbXaB3LU28//hXouZZKBuXLs8Bsew2BVk ZXCRSLPh6tGfvNE4XuL0KyqZgQUOnVze6ngIV9QiXGaBOFMjG/N6GjogspQG9wKPE9my o8W+piNbE09h7F39EfkCItn+GmKRWijdanbDBN7jLLRTXN63X58dczP2QsW29zgvnDLe 12VQ== 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=RfCMCXrYA1B7hdl4+HTn56eOFcFdIZ1MngaEqknT0CQ=; b=p1njkoK/Y6Ln3TjHlu1aiEhTKxbk9hY5QzLM+8hTHAvBNA/RNgsJwuB+Q5bEqq690Y kFr3uM82HZTmLjHX2+W5tKK330PaUUHitRQuTLBEEKTH21zTILvt+rDErw+LQ7GUAKoV uylrlEpE5nLAzy3iT8QShgy/H3ueP5kLvu6aT7muQAbuGV40JTMaaEvtu0U0uIoymqCr MNi0dEj28aK19RZYPHGrtSAyx/4yaMkA+dX7NAihM/epxlXe5Er5KC2jEUhpQSNNEEdu p4mz+pWReLvnsL1qu6xsY5+AVZYA7Sh0hYae0mvzCrL2OpAA0Vf75xFh3CTVisu1k5RQ BDuA== X-Gm-Message-State: AOAM531e3DpRmQE91Qy/jOJetQ/ieYaoVdCh9if/1dW9pR8sYu0rN7dJ tpxsldM/7MYbQuwyBt7Jym2qSNUZkAY= X-Google-Smtp-Source: ABdhPJzTdWRnQvF2iDCcsoZXEIJ3jJb2530a0FHPTPvv4JslmLpOIbwO985pL/lreNe1br/EI1r1ew== X-Received: by 2002:a17:906:264b:: with SMTP id i11mr6228017ejc.485.1630011616770; Thu, 26 Aug 2021 14:00:16 -0700 (PDT) Received: from localhost.localdomain (84-236-78-211.pool.digikabel.hu. [84.236.78.211]) by smtp.gmail.com with ESMTPSA id q14sm1884779ejc.93.2021.08.26.14.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:00:16 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Derrick Stolee , Thomas Gummerer , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 6/6] read-cache: fix GIT_TEST_SPLIT_INDEX Date: Thu, 26 Aug 2021 23:00:04 +0200 Message-Id: <20210826210004.672860-7-szeder.dev@gmail.com> X-Mailer: git-send-email 2.33.0.358.g803110d36e In-Reply-To: <20210826210004.672860-1-szeder.dev@gmail.com> References: <20210817174938.3009923-1-szeder.dev@gmail.com> <20210826210004.672860-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Running tests with GIT_TEST_SPLIT_INDEX=1 is supposed to turn on the split index feature and trigger index splitting (mostly) randomly. Alas, this has been broken since 6e37c8ed3c (read-cache.c: fix writing "link" index ext with null base oid, 2019-02-13), and GIT_TEST_SPLIT_INDEX=1 hasn't triggered any index splitting since then. This patch makes GIT_TEST_SPLIT_INDEX work again, though it doesn't restore the pre-6e37c8ed3c behavior. To understand the bug, the fix, and the behavior change we first have to look at how GIT_TEST_SPLIT_INDEX used to work before 6e37c8ed3c: There are two places where we check the value of GIT_TEST_SPLIT_INDEX, and before 6e37c8ed3c they worked like this: 1) In the lower-level do_write_index(), where, if GIT_TEST_SPLIT_INDEX is enabled, we call init_split_index(). This call merely allocates and zero-initializes 'istate->split_index', but does nothing else (i.e. doesn't fill the base/shared index with cache entries, doesn't actually write a shared index file, etc.). Pertinent to this issue, the hash of the base index remains all zeroed out. 2) In the higher-level write_locked_index(), but only when 'istate->split_index' has already been initialized. Then, if GIT_TEST_SPLIT_INDEX is enabled, it randomly sets the flag that triggers index splitting later in this function. This randomness comes from the first byte of the hash of the base index via an 'if ((first_byte & 15) < 6)' condition. However, if 'istate->split_index' hasn't been initialized (i.e. it is still NULL), then write_locked_index() just calls do_write_locked_index(), which internally calls the above mentioned do_write_index(). This means that while GIT_TEST_SPLIT_INDEX=1 usually triggered index splitting randomly, the first two index writes were always deterministic (though I suspect this was unintentional): - The initial index write never splits the index. During the first index write write_locked_index() is called with 'istate->split_index' still uninitialized, so the check in 2) is not executed. It still calls do_write_index(), though, which then executes the check in 1). The resulting all zero base index hash then leads to the 'link' extension being written to '.git/index', though a shared index file is not written: $ rm .git/index $ GIT_TEST_SPLIT_INDEX=1 git update-index --add file $ test-tool dump-split-index .git/index own c6ef71168597caec8553c83d9d0048f1ef416170 base 0000000000000000000000000000000000000000 100644 d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 0 file replacements: deletions: $ ls -l .git/sharedindex.* ls: cannot access '.git/sharedindex.*': No such file or directory - The second index write always splits the index. When the index written in the previous point is read, 'istate->split_index' is initialized because of the presence of the 'link' extension. So during the second write write_locked_index() does run the check in 2), and the first byte of the all zero base index hash always fulfills the randomness condition, which in turn always triggers the index splitting. - Subsequent index writes will find the 'link' extension with a real non-zero base index hash, so from then on the check in 2) is executed and the first byte of the base index hash is as random as it gets (coming from the SHA-1 of index data including timestamps and inodes...). All this worked until 6e37c8ed3c came along, and stopped writing the 'link' extension if the hash of the base index was all zero: $ rm .git/index $ GIT_TEST_SPLIT_INDEX=1 git update-index --add file $ test-tool dump-split-index .git/index own abbd6f6458d5dee73ae8e210ca15a68a390c6fd7 not a split index $ ls -l .git/sharedindex.* ls: cannot access '.git/sharedindex.*': No such file or directory So, since the first index write with GIT_TEST_SPLIT_INDEX=1 doesn't write a 'link' extension, in the second index write 'istate->split_index' remains uninitialized, and the check in 2) is not executed, and ultimately the index is never split. Fix this by modifying write_locked_index() to make sure to check GIT_TEST_SPLIT_INDEX even if 'istate->split_index' is still uninitialized, and initialize it if necessary. The check for GIT_TEST_SPLIT_INDEX and separate init_split_index() call in do_write_index() thus becomes unnecessary, so remove it. Furthermore, add a test to 't1700-split-index.sh' to make sure that GIT_TEST_SPLIT_INDEX=1 will keep working (though only check the index splitting on the first index write, because after that it will be random). Note that this change does not restore the pre-6e37c8ed3c behaviour, as it will deterministically split the index already on the first index write. Since GIT_TEST_SPLIT_INDEX is purely a developer aid, there is no backwards compatibility issue here. The new behaviour did trigger test failures in 't0003-attributes.sh' and 't1600-index.sh', though, which have been fixed in preparatory patches in this series. Signed-off-by: SZEDER Gábor --- read-cache.c | 23 ++++++++++++++--------- t/t1700-split-index.sh | 11 +++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/read-cache.c b/read-cache.c index fbd59886a3..335242c1cf 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2824,11 +2824,8 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, } } - if (!istate->version) { + if (!istate->version) istate->version = get_index_format_default(the_repository); - if (git_env_bool("GIT_TEST_SPLIT_INDEX", 0)) - init_split_index(istate); - } /* demote version 3 to version 2 when the latter suffices */ if (istate->version == 3 || istate->version == 2) @@ -3255,7 +3252,7 @@ static int too_many_not_shared_entries(struct index_state *istate) int write_locked_index(struct index_state *istate, struct lock_file *lock, unsigned flags) { - int new_shared_index, ret; + int new_shared_index, ret, test_split_index_env; struct split_index *si = istate->split_index; if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0)) @@ -3270,7 +3267,10 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock, if (istate->fsmonitor_last_update) fill_fsmonitor_bitmap(istate); - if (!si || alternate_index_output || + test_split_index_env = git_env_bool("GIT_TEST_SPLIT_INDEX", 0); + + if ((!si && !test_split_index_env) || + alternate_index_output || (istate->cache_changed & ~EXTMASK)) { if (si) oidclr(&si->base_oid); @@ -3278,10 +3278,15 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock, goto out; } - if (git_env_bool("GIT_TEST_SPLIT_INDEX", 0)) { - int v = si->base_oid.hash[0]; - if ((v & 15) < 6) + if (test_split_index_env) { + if (!si) { + si = init_split_index(istate); istate->cache_changed |= SPLIT_INDEX_ORDERED; + } else { + int v = si->base_oid.hash[0]; + if ((v & 15) < 6) + istate->cache_changed |= SPLIT_INDEX_ORDERED; + } } if (too_many_not_shared_entries(istate)) istate->cache_changed |= SPLIT_INDEX_ORDERED; diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index e2aa0bd949..decd2527ed 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -533,4 +533,15 @@ test_expect_success 'reading split index at alternate location' ' test_cmp expect actual ' +test_expect_success 'GIT_TEST_SPLIT_INDEX works' ' + git init git-test-split-index && + ( + cd git-test-split-index && + >file && + GIT_TEST_SPLIT_INDEX=1 git update-index --add file && + ls -l .git/sharedindex.* >actual && + test_line_count = 1 actual + ) +' + test_done