From patchwork Tue Sep 3 22:06:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lyles X-Patchwork-Id: 13789457 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E1161D58A2 for ; Tue, 3 Sep 2024 22:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725401214; cv=none; b=OqvpvC+EOTaWnm56dc+Nndsvd40dtEIESikrU6DJ2C659p1fPSlgcOU5uDLNxr/AJ0ki6Qm2CjUmEcDyRKLrrIzZ60VBv1um7zJDEHD8syiWHf1M/wchyvXKMV8xLvCR9ZEz4wlaIV9pQoJaQ0V5OuDgIxO01dX4U+Fy1gqFY+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725401214; c=relaxed/simple; bh=y3vvVP6IwvuIFwKPTuSdOLOsBfuXRyYpS0D0qUnkmck=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=t8udroVu8J5WdG8WTHPixO03terZD1ROp3Au7TLhNx9hRATJJn50rYQZmmWSghcyyL/cXEDMSsBAJ8yhABzQ37uFHCGUQ4VhBlzgn24C7I4DwuTbqN8PUcNKTUNZth3EhaE6tN08eHKo0kkiPQ3zZdmMX+vwTkOkUEHF4+oTSdc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XP0BHhtm; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XP0BHhtm" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-58ef19aa69dso5531774a12.3 for ; Tue, 03 Sep 2024 15:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725401211; x=1726006011; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=WiLCQgSI0RN/qaGSBlsSMDWWC7ZyEXa22FwToiJZsjI=; b=XP0BHhtmMHupzyjnyPLFH8Vqyr5fUuiI5QaTAgzZMYssR0N3DyKSmKm0/f7KniMqwe G3UDaOY2YkaKRazr0LJJTk+PXefyLo3FG2c3+fObDSiBaHmKmBcY3GWqkxl45/lvOTcs BXApeBSPYCXUKYEnTmryTgfQ5P/1Vdrl2fOtsMv0tCaYRP+tuxxzLxamQ4LIfwZY2olf cPJbZPQQcbbhKMIyIKeAzjDJk65AdKNfc86arLLlnm0NOSH9EG2XRHFkjFRNXe9Vlg67 zDsXzjdDT8EYWAWuokvIKmZ5A86Gl08K+Y3iqYDfJVY1qW12CjvhgI+fraY2kG0QStI2 HXNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725401211; x=1726006011; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WiLCQgSI0RN/qaGSBlsSMDWWC7ZyEXa22FwToiJZsjI=; b=t5w8+tncTmo70HBu5rZlqILq7kHzEQ+//GnXqzjX14e3nt79h/yfBXbL8jI/hnFdxu fsV9epqWsz+2p+yQ/D/tLm0kwqR5VkEELSrewc732nA74gbXwg3GDWFfDkWDUai0FwXH fW8DrR1MIlUzAVlGmdM+TbbZRI479eIlIIbTUOpXYTy40bqU/AuvCII4floUeAGZJ6Oy Kca9NbqjJmW4mYKOldG4i1/HXHc9FhySbyqZ1VvrmM0/UBNymST+gjc44oqWbGVTKz9/ 3tSuE1hrHnt1PN0yPgDjpas/FwXJDebUTp5vziirhHjO8faMfKQP/WCiwLI/0Epd6bcl +kJQ== X-Gm-Message-State: AOJu0YzuA/84SqMScZsoX5h9TgR8LLCayl9fcmqpRep080nIffkzLG7+ ky63tinmZr1fX/dU78pOh+8Xyf+1q1+Ifo8kUKOS0r1CGx/1IwFCp2ejcw== X-Google-Smtp-Source: AGHT+IGeTetnlc7RYne4rFkCTKR2xGT/8xNyOW3KnttFgHFVmGVPZInRPMYV3RnocebNYz5/JkajkA== X-Received: by 2002:a05:6402:13c8:b0:5c2:1f74:114f with SMTP id 4fb4d7f45d1cf-5c24301db2emr8904315a12.34.1725401209677; Tue, 03 Sep 2024 15:06:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226c6a40bsm6864721a12.19.2024.09.03.15.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 15:06:49 -0700 (PDT) Message-Id: <73fe71abcd578316a81615feee9561015c2a1c53.1725401207.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 03 Sep 2024 22:06:46 +0000 Subject: [PATCH v4 1/2] t1092: allow run_on_* functions to use standard input Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Junio C Hamano , Kevin Lyles , Kevin Lyles From: Kevin Lyles From: Kevin Lyles The 'run_on_sparse' and 'run_on_all' functions do not work correctly for commands accepting standard input, because they run the same command multiple times and the first instance consumes it. This also indirectly affects 'test_all_match' and 'test_sparse_match'. To allow these functions to work with commands accepting standard input, first slurp standard input to a temporary file, and then run the command with its standard input redirected from the temporary file. This ensures that each command sees the same contents from its standard input. Note that this does not impact commands that do not read from standard input; they continue to ignore it. Additionally, existing uses of the run_on_* functions do not need to do anything differently, as the standard input of the test environment is already connected to /dev/null. We do not explicitly clean up the input files because they are cleaned up with the rest of the test repositories and their contents may be useful for figuring out which command failed when a test case fails. Signed-off-by: Kevin Lyles --- t/t1092-sparse-checkout-compatibility.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 6fa7f5e9587..4cbe9b1465d 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -179,22 +179,26 @@ init_repos_as_submodules () { } run_on_sparse () { + cat >run-on-sparse-input && + ( cd sparse-checkout && GIT_PROGRESS_DELAY=100000 "$@" >../sparse-checkout-out 2>../sparse-checkout-err - ) && + ) ../sparse-index-out 2>../sparse-index-err - ) + ) run-on-all-input && + ( cd full-checkout && GIT_PROGRESS_DELAY=100000 "$@" >../full-checkout-out 2>../full-checkout-err - ) && - run_on_sparse "$@" + ) ... " " ... " +# Usage: test_sparse_checkout_set " ... " " ... " # Verifies that "git sparse-checkout set ... " succeeds and # leaves the sparse index in a state where ... are sparse # directories (and ... are not). From patchwork Tue Sep 3 22:06:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lyles X-Patchwork-Id: 13789458 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ED9A1D88C3 for ; Tue, 3 Sep 2024 22:06:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725401216; cv=none; b=AKtblKJg9GLJzhXh+CybckaG8FRIthkQNt9Rin3HUCXJQQUzOvFXbkom7HVrS5/27vUn06EkvstgR4yRfHSmYyIEjqSluflRRIwZW+CI0tg+TCa2lVfCrpg6UY2Cy+4ubmkdd3sEY/OTNjM/gwRR+p2vHI3Z9FGhYFii76cH7aY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725401216; c=relaxed/simple; bh=k3zqn/w4HkRx5sqHTuYeI4pIkAW4NRjhqcgFW4oEVdQ=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=SlUVLSA5y3wE/IOLVXWXa2vYRazODAgFis4y3pZiZs9CzcV7WSEOl8DaOBMJ5BEEsDwVS4lFQA7YY+BQSaV7MYS1ygomgZCkI8HKw3US2x3XIWSqVdRNkreYXJgyN9h+RO8dAUE5ghYpf5xj8xuAYLiDQ5v88CVwfk4ShVDL2yk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bTP6Te03; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bTP6Te03" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a866d3ae692so339353866b.0 for ; Tue, 03 Sep 2024 15:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725401211; x=1726006011; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=/yMnIJkTJjce0gXAPjc03uZ/yS9kmwpi7BaT3dAzcQE=; b=bTP6Te03Mc/kTSaRwo9Hlp8Kfribb3/CYWVHDGOnidwMPM0p3PetGx2ycl3c8kYAVk hxpDPkkj+Ult7L2o+W5Wwg4xCfuBmLOCkyJV6ijdwivE1cbZ8TMHqZdUyn8nU412wXIH SCajRckqpwVHyQUJqwi9aIhnSgNPlRM3rE9Vyn9VXayZoqWu5wD3yYtkwMbCb5pz41Ht k4ooNG+/wmMicU55OTj1RrFaWcFLQ2UjVG+xGOMuTyiT9phv+jsjVS88V5x0ekigQfLp 1l+1DsMdeuPvSnS7n3oKLTMMt24+p3L5Pt1XOeE6X+4dFQnrrogNFbf0EIf9MaKm1/lL jppw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725401211; x=1726006011; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/yMnIJkTJjce0gXAPjc03uZ/yS9kmwpi7BaT3dAzcQE=; b=nQHnaYBiDtHqX5eoDjwWMZJz3oWCYQ/M78IRZdkjQvJJfnYmgPCee5D2E781c6J/mc UDYmZV1IBwITyMzOtEkTeytUTr9DZTbOS1WyEDeJE/UNgX5zHt7vb28lcHqVQfvRSHh7 /a4PBk6lUbk0bSE6OD8AB2w5n0iAjFP1vduybSdqVSJfv4ukqeiKeMRAl0GbXt73VysT kpYAtNWpw6uEChWbrsj0S8Y+rFHbran0CSjLc3/vH8IEH91/vFWq1E+UF6bodxAyouS9 FdAPUpfxHqSVqKIY+8kOOB2aKic1shVAiqn5bVU+qLuSoGBJ14Zu9PhzfUqtvwJT/Jmo np5Q== X-Gm-Message-State: AOJu0YyU0o/Vm7DxgilIL0GMf3c61ruNZ2ouwnyMnTFsDgC49XaP6VEz cXm3lsWOfQXdGZj2Ns54pa9FJHU3jEEJFb20nVvUsHbFc+5taFqn03w9Kg== X-Google-Smtp-Source: AGHT+IE2rg+ICD+Ui0bcw2akoE0kV02bXM8JOBHf+QADRtkNCQs0EGLyND13AJVcClINXzFNnqdR1Q== X-Received: by 2002:a05:6402:d08:b0:5c2:1803:ac65 with SMTP id 4fb4d7f45d1cf-5c21ed54d08mr17128815a12.21.1725401210330; Tue, 03 Sep 2024 15:06:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c24b5ad63dsm4447658a12.80.2024.09.03.15.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 15:06:50 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 03 Sep 2024 22:06:47 +0000 Subject: [PATCH v4 2/2] builtin/cat-file: mark 'git cat-file' sparse-index compatible Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Junio C Hamano , Kevin Lyles , Kevin Lyles From: Kevin Lyles From: Kevin Lyles This change affects how 'git cat-file' works with the index when specifying an object with the ":" syntax (which will give file contents from the index). 'git cat-file' expands a sparse index to a full index any time contents are requested from the index by specifying an object with the ":" syntax. This is true even when the requested file is part of the sparse index, and results in much slower 'git cat-file' operations when working within the sparse index. Mark 'git cat-file' as not needing a full index, so that you only pay the cost of expanding the sparse index to a full index when you request a file outside of the sparse index. Add tests to ensure both that: - 'git cat-file' returns the correct file contents whether or not the file is in the sparse index - 'git cat-file' expands to the full index any time you request something outside of the sparse index Signed-off-by: Kevin Lyles --- builtin/cat-file.c | 3 ++ t/t1092-sparse-checkout-compatibility.sh | 36 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 18fe58d6b8b..1afdfb5cbae 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -1047,6 +1047,9 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix) if (batch.buffer_output < 0) batch.buffer_output = batch.all_objects; + prepare_repo_settings(the_repository); + the_repository->settings.command_requires_full_index = 0; + /* Return early if we're in batch mode? */ if (batch.enabled) { if (opt_cw) diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 4cbe9b1465d..eb32da2a7f2 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -2358,4 +2358,40 @@ test_expect_success 'advice.sparseIndexExpanded' ' grep "The sparse index is expanding to a full index" err ' +test_expect_success 'cat-file -p' ' + init_repos && + echo "new content" >>full-checkout/deep/a && + echo "new content" >>sparse-checkout/deep/a && + echo "new content" >>sparse-index/deep/a && + run_on_all git add deep/a && + + test_all_match git cat-file -p :deep/a && + ensure_not_expanded cat-file -p :deep/a && + test_all_match git cat-file -p :folder1/a && + ensure_expanded cat-file -p :folder1/a +' + +test_expect_success 'cat-file --batch' ' + init_repos && + echo "new content" >>full-checkout/deep/a && + echo "new content" >>sparse-checkout/deep/a && + echo "new content" >>sparse-index/deep/a && + run_on_all git add deep/a && + + echo ":deep/a" >in && + test_all_match git cat-file --batch in && + test_all_match git cat-file --batch in <<-\EOF && + :deep/a + :folder1/a + EOF + test_all_match git cat-file --batch