From patchwork Fri Aug 30 21:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lyles X-Patchwork-Id: 13785576 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 E34B61BF7E5 for ; Fri, 30 Aug 2024 21:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725052250; cv=none; b=BUrs28MQxlFTcLUKCCmIk1IypPQ0G8/cex2YRC9lwM9xLM5Rb/dK+XiPtK4MVqI4djFtzeBSsmR+iVMk3OYmsaRDKMzrQMeYON1D7Sjr0slTTdgCecx1HYCDK7mATuEXkzG0jVyXHXC9tGkuJhF3ABYsg6NfTSiro+I0fgn5oGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725052250; c=relaxed/simple; bh=hqERkU8Xv4p4J68xvsqCxpbXzO90U+55m1cyNyH8Lj0=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=kSfBr9T9BLHoSf/ukhY+/DU4foHkR6AYFqWEGryBCfA1iUx1CjxccexA9AJWcw4dPDy72kB/DkTuYDG+o7/nHFnRZHDElQK6JuVGZLQB/+TQR8l/VnfmChqSb+ex6XHWAQI/5dX0JPZR+Sm0I4coaqDQeuJwRwLvva+rW7RI7Vc= 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=UPrVsPI+; arc=none smtp.client-ip=209.85.167.47 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="UPrVsPI+" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-53349ee42a9so3076842e87.3 for ; Fri, 30 Aug 2024 14:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725052247; x=1725657047; 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=GKkzs1Kz9im3O36eraNjz8vseVQfkUVd+C+hugEctJY=; b=UPrVsPI+Qw81VldinNVnC595n7gZAsj5ifhcOeFun5j5vEE39n+JSokGUCLTK4NQs7 id7FelHuSr6hskOmENVnw42BViRAoOcW/aWQj286w/N+hg8ZXzRkF/m2Ct60Zd9bvBll cj4JT0qm+rmi+C1ZY8nb4b+wxuwmCEWnxiSKys8HNs7DgI7Ryddk5xQ+5ccq/53LK5el sJrEnRfZ+THKKTRTSm2t9BbXt4U7yFS4erSJ+NFPoRT2EAxgzLBLDRpc6HN1yKryKo21 4KJgB5CzyxmyfjZrmu4FQMlZpI+71oA1teu9LuqFGfk4oNXsj7y4ys1CvpE43o48HAYO Hn9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725052247; x=1725657047; 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=GKkzs1Kz9im3O36eraNjz8vseVQfkUVd+C+hugEctJY=; b=oPrag7sBm6QvweAIISaNiKn9fYQyzPQQk2AGF7TPncvBrFxqYoJh2FkBZW2IKZNzny eQ16iQvC2PYgmjxL69/HE3SEEI4o/bXRY9uYVHECZMqW4D5laCoVR4KZjFn/aTs3KJG7 LRzdaeTeL7qX6Aw9JZDMqoPzDcbh7aqT4OiqQKz09DwzGhOk28LYNPQinzOewgTth9Yb 5x9ugnv4RwWtCGlqsU7QKfS/qIE55XNcxGkXlOU6SwBtQkx2VcLwFW8VR5ba/q8Cfaap NetcYVxhgcJ13gr0k4X3ST3sWbG2VXyNWX32JsOKCjfbai8WFfp/9Zy/iXLC1usw+bYW XIVg== X-Gm-Message-State: AOJu0Yzaf4bWWnQV/WqcxDLxc71JN2wh8NiaCy4ULjoxDASRFg9arYxR Lz3sa3jXqSoo6LC5cgeNLNfXwM6nk/36dUIAUlnXAdUyLYkdmR6zde3u4w== X-Google-Smtp-Source: AGHT+IGlbk/5X96gm1GbvMloiZ5NHIh8zFNjvW4b4Tlg6x4QI/OeIt3FiL/VU8YjP69ZmJqAhnGrdw== X-Received: by 2002:a2e:a590:0:b0:2f3:ef3f:2289 with SMTP id 38308e7fff4ca-2f6108922c1mr55052521fa.35.1725052245833; Fri, 30 Aug 2024 14:10:45 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226ce5463sm2295248a12.84.2024.08.30.14.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 14:10:45 -0700 (PDT) Message-Id: <7067a4c5da2cc8af61cc0f92940eb7b1ae299390.1725052243.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 30 Aug 2024 21:10:42 +0000 Subject: [PATCH v2 1/2] Allow using stdin in run_on_* functions 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 , Kevin Lyles , Kevin Lyles From: Kevin Lyles From: Kevin Lyles The 'run_on_sparse' and 'run_on_all' functions previously did not work correctly for commands accepting standard input. This also indirectly affected 'test_all_match' and 'test_sparse_match'. Now, we accept standard input and will send it to each command that we run. This does not impact using the functions for commands that don't need standard input. 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 a2c0e1b4dcc..b140b642b21 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 Fri Aug 30 21:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lyles X-Patchwork-Id: 13785577 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 945751BFDF0 for ; Fri, 30 Aug 2024 21:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725052251; cv=none; b=uTdFjeULrbSj7nQyQUyBSN1LgCiQkPlePptvl5k3sySJ8igimiimfue0fhtJYHacm44IvcpwC4o/50umh3I3N7EOsgGTRYlJbQ0AUk+SJXApTvJ1QBzcxQog7w4eO99GC5pO0ZIU+MvpxMzuJ0TqEbaHcf3QnG2q3nDF4N/zIdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725052251; c=relaxed/simple; bh=BmJ0ERBnjLMeV/LUhc9sq7abNs9bKuLnjbdPHIKy0D0=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=YwASBxlNEvCAPckw1Lm0H2XXaAu5uWZ3utJrhFySUzsSaz9+FbNe4WLntAH1KVkrn5vS00eb8LsWsG6uxoPQo1rDWEy3klfRsfnvvEPDHPDxDA5gkFvy1WKWa2r0OYEO5aVN3wY0zk4tk1gi0IsHxVATCvvYXCStRm5SvJfVWdU= 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=hUzyYlgo; arc=none smtp.client-ip=209.85.218.49 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="hUzyYlgo" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a868d7f92feso270398766b.2 for ; Fri, 30 Aug 2024 14:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725052247; x=1725657047; 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=X7Tep8SsL3ZpfKfkfrHx24hebf2Rej7JLc7+8vrAqMI=; b=hUzyYlgo0wccUNjQ4mnzoAHuRJiWi/dx/iMKWkACloLGlwEZTboeA0Iac+1pD0tP12 U2A1rndZob8zMstqfmiP413/JuINZLrJfL/4Da1UuBvAQg6f12HMFhNKjXyd5jZOD7gJ ayE5JzIbmMKNuO/rC5GT+nX8EyM45VKyAaslWUyTCkrgN7dPt1KQb8KUVslJohKAAXDK dOCU4IZ/YFp9zBB9A5pKIo8JTxJZmnRqIbQj+8k96cO7/pYrlaYYGrLlzRGJkE+3dboS 63hbiT2lG/GKDTe+ceCXD3fZyp//rgDvhmlEjUbh4UNkStSVQlZwLb6Y2lWhkcYYkfmS JCrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725052247; x=1725657047; 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=X7Tep8SsL3ZpfKfkfrHx24hebf2Rej7JLc7+8vrAqMI=; b=NTlMaXI5BnCKmvizFepCXabnBA5exIdgKnjbMtNWxIumkOb35F7GUHNCLx1t59gM2z Hzbn2QQ2clM6g0SdtJ1zsS4HQP4wi82GEuEW0wKKXkP0lM9iL3CzRPg7DWvC6zR1RcWh GAJjoR0jEJMG8T54ykBvJU+S1pnYqtMBZChLtJtFbjYlk3xoGoBaX9eQnxV8OevM/Xmy BhZmJPXZ/VxeJAKQ3dJzgtAbvGR2jDsifWoKDC4hUW3UvqczR1Pv/6poTk7hGnWnSk4b E4JEROTl42IVYi6vMyu5e/e/oGOJYIa6FrNZLDav1o6Z40X/an9HV2eMVdqwMicleUwg c6kg== X-Gm-Message-State: AOJu0YwGNsM9XplTkRT3SokS4SGEaHXgZAz0/1zMtX24GxKsAP6TbrNm rKnT6tjpLfsdwgZvDl8eZhMlh9gYSmwB/L4tvpxv6z29EblKtO/sNoCl2g== X-Google-Smtp-Source: AGHT+IHLX8vqgSIqLMXRy0XDiaylpzT0woSRxqky23Of0JVunWsxSn2STFYnZ2NcqeABWF/Y40ozrA== X-Received: by 2002:a17:907:3208:b0:a87:31c:c6c4 with SMTP id a640c23a62f3a-a897f83623fmr609053666b.24.1725052246827; Fri, 30 Aug 2024 14:10:46 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891da22bsm252535066b.182.2024.08.30.14.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 14:10:46 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Fri, 30 Aug 2024 21:10:43 +0000 Subject: [PATCH v2 2/2] 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 , 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' will expand a sparse index to a full index when needed, but is currently marked as needing a full index (or rather, not marked as not needing a full index). This results in much slower 'git cat-file' operations when working within the sparse index, since we expand the index whether it's needed or not. 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 | 34 ++++++++++++++++++++++++ 2 files changed, 37 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 b140b642b21..4d025c5f8d6 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -2349,4 +2349,38 @@ 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 && + :deep/a + :folder1/a + EOF + test_all_match git cat-file --batch