From patchwork Tue Sep 3 17:54:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lyles X-Patchwork-Id: 13789169 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 7F02218FDAA for ; Tue, 3 Sep 2024 17:54:09 +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=1725386051; cv=none; b=YfEdWzBoq6Gv055r3tqr3O4Icp0XzasdLVj8BpT0FlTfoxb5+59RhuEBC7vbw6OCYy5fKF43W9yZ1YwfYK3oFeO/4ZlFurdWoAwjRLU7xWNEWkNPgmangwBDIZPOyir6c50kxHGKVQylhAnHyxehGKFbXAwrwiFKjetA3K7ekxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725386051; c=relaxed/simple; bh=eMInr5ADkvmLVMCudz6dvvBhqsdNt1eKuHt0axIGsMg=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=L3S3xaGOZvikYc3u1gsQrLM8OK0X9nxxYXxDkCCYt+adnAJPlwHdnfN3g9uLazMmglbxNYyYAMPtLxyXGKEVE9szMqdqdD7jQ/NWQSXPYmhhpeqvXU3X1Fow/54d0D5CWYmKBlFmV2O3QYSbOu2rMd7FKnGvvo+jKqrBTYNuGDU= 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=Rud68Gx4; 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="Rud68Gx4" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a86fa3dea99so309457766b.2 for ; Tue, 03 Sep 2024 10:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725386047; x=1725990847; 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=CW54UX0NTzJEGMgEhLkQ11JbtBNm6F1fIpG8tR/3b4Q=; b=Rud68Gx4rqDvWPXZnB4UFljyp7SioqzhfdEFHw4l49AFEOwERwS1G3Zist47UEupsD yCb5AmFtD08nlTUVSDl8w8WmvfAsfayPe+xgYPA+xQxPcNZifKpmn1efnJ3ftqvhQu3a xk5nQsvmDVuZgtbvTQLPdePiVXf2hGfeMRTjCZRDklrCd5Et4yTyZLt3lwM5ZUqk7vKz vs2pfvGvFjCdVNPi3SooEeEuQvLv6Se17yIeeFIQ4c3+wCjvg5k2G25cLLXLm1WqKyBg iBNGG3JTJ4qndj590SphiM7emZuTE3rzPYzLTAiBHXcYfAD+erJa0GxINRu6mqe4+syT hMoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725386047; x=1725990847; 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=CW54UX0NTzJEGMgEhLkQ11JbtBNm6F1fIpG8tR/3b4Q=; b=d3KyfoOhaz30whamTfDYakSrPLR+bAxTOxtLOYZGB+89Y7iV2clrdjSijkijReHM5P SHG++O+CA2klLd/LlhcV8rzdf9VhKSDEXD8WX9Ui3OkpfBfpvh6B9x2dTdyqTW3YJykN ydEJPLLzkNCvfWNxg5LwEUoqmLKlQzvScJiW44kRVQVeykSJZN5+2UMIqS/t8fjyPMSR w3a3gQn6+rRXGgImINGAiGBRaOC3C5Ac2jLr0Gz1WrvLiJ/+l58FYEmbH2TicBx8s+Fh ssrdU5HnEOuy+HZN64TgpK1mTcxmCNS4obqW+TjP65uhFe8DOHrUcsslmomb/06Xdu/a sWPw== X-Gm-Message-State: AOJu0Ywk0F46uU+T4+DVUsHW2uTI6nnMt6szpxfgyYpplOUGTNWDlQqG 7VIpHxhrduK/tfUJHTZ/qi/h+dNm4pAFvqyTBguGo20zbjOF7aZjrTuAew== X-Google-Smtp-Source: AGHT+IE2l9idJSH5JVcZ/w9GAGL5a+S+F5OjqNE0fIHCJaKYdIt3GCrT8IgCbYme7vtR7zzLcOTxEQ== X-Received: by 2002:a05:6402:40ce:b0:58b:1a5e:c0e7 with SMTP id 4fb4d7f45d1cf-5c21eda0d11mr18499907a12.35.1725386046887; Tue, 03 Sep 2024 10:54:06 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89892221cdsm706167966b.207.2024.09.03.10.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 10:54:06 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 03 Sep 2024 17:54:03 +0000 Subject: [PATCH v3 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 6fa7f5e9587..87953abf872 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 17:54:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Lyles X-Patchwork-Id: 13789170 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 6D6FB18FDCD for ; Tue, 3 Sep 2024 17:54:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725386052; cv=none; b=V/lLw6ddCTzQ4q4qq0gw7AUb6JGNOg8Q1/HwzLEfuCfPe2wlX9EwIRmAwsyNmRb3uTRoDsxQFALW+tc9kHGbbwceF3KKSCLFV7HH0diHZZrAbavHZLjpWiIfsdpCK54L+PDYyukD2D4b5nHe6JoASdKF/Ds8ftEyOQn1pXL7uIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725386052; c=relaxed/simple; bh=sKQy44pXHETObVbz89Z90/ZeU3cjIUJqakFc5R7Xadk=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=UcoiHONkhGkevQr8sqBHWBttOEYx9rEURsckbQxofPZIM47AHH2PxrcHA53wVgI60geya++0cXC/ahEGxRt/A+6orUc/rmrVflm8A5xvdshcp8Dqta137sI3hSq7LxgrjqU0n8sVIhOVCHdEaYpparGtZWAYM2oGqA/3a8IA7E0= 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=DunsOhIv; arc=none smtp.client-ip=209.85.218.52 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="DunsOhIv" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a8696e9bd24so664479666b.0 for ; Tue, 03 Sep 2024 10:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725386048; x=1725990848; 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=S0o5uiUSXnKY0Ql+yTadctJhr2MQZdTo+sASYu/abx0=; b=DunsOhIvx+ih62umWL083koNqBSaydR3KyszFFHJ2JzMMsoW1Y7P07kgjG6TAhPtxJ WXTw6JHSEiIVe3YL12G10TrgS+lJ+UwlUkDb+tqELQnKPcjZVi8vDTejRteP/NXYB/Cd UhmGVxeEAmJL5gAG5j+9k1aB3EoYekUtkj1SZCE7q+186KPXSqU701wGNdqvYgvmyrjM a9D+b0CE0Mr89f5RiOoIxQ8utlSh0Tk7X9eGaODuibfNpyp5HMOo3qODbpHfHfigdgJf TRaTNjACnzY2cHzFnxpJ8ba4l8c8etNEnirG2KBykaDR20JTskVnpyPszwTglfR8gbAs UsMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725386048; x=1725990848; 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=S0o5uiUSXnKY0Ql+yTadctJhr2MQZdTo+sASYu/abx0=; b=qrpRe/waCG6gU9KcH4hwvUQH5fiTl2UCiX/exeDv8NA/r3lHl3PN69+XD8jRMwNsyJ u+PWhijtzmXUtr6f3fUWLEs2337ZDY8co8Fb7StOdxGuKi3AILwHiVoVzUOFWXoeQdYW HLmoan2h+TkMlsnJZ5sGpKd0WErUjWTxJFgehGWfEOR2PlqGxUtLDgfY4fmC+jwY1P8U 48zQiAaeq86pcO9dSyBNSnfoiZ7eywgfW6iCze4LmqVDbzjjyUEXOdMjpTo9cKuDQk9X qAVnvehknsZ+IqIM6ZubrukyV9R54WrTaA1YVAL3UNkZO46URihJo+VMrM8MDvd26cGJ GdxA== X-Gm-Message-State: AOJu0YzcsR3RsDSNFTePdaCTI6KeLekz6XXU0Yyp/PQrZUL/ZgjOJVgZ VBkwd6Lvvm4UwSf0gQpaVaJeDVonuiBrJg4Jp1A59OWXehmxizeMgAbuvg== X-Google-Smtp-Source: AGHT+IFEt3oQwBG6DJPmcr6Q5INrZjaQl2iPTnkhu4AWwCoiBUwKANBceJ0MndGGM5SkEIm2Mb4Jyw== X-Received: by 2002:a17:906:f589:b0:a86:8f2c:5cfa with SMTP id a640c23a62f3a-a897f789236mr1331596066b.14.1725386047923; Tue, 03 Sep 2024 10:54:07 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891d6d88sm711090466b.151.2024.09.03.10.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 10:54:07 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 03 Sep 2024 17:54:04 +0000 Subject: [PATCH v3 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 | 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 87953abf872..fbc10c8042b 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