git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 0/2] Mark 'git cat-file' sparse-index compatible

From
KGKevin Lyles via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 3, 2024, 17:54 UTC
Message-ID
<pull.1770.v3.git.git.1725386044.gitgitgadget@gmail.com>
In-Reply-To
<pull.1770.v2.git.git.1725052243.gitgitgadget@gmail.com>

Please note that this is my first contribution to git. I've tried to follow the instructions about how to correctly submit a patch (I'm using GitGitGadget as getting Outlook to do plain text e-mail correctly seems impossible), but please let me know if I've missed something.

My motivation for making this change is purely performance. We have a large repository that we enable the sparse index for, and I am developing a pre-commit hook that (among other things) uses git cat-file to get the staged contents of certain files. Without this change, getting the contents of a single small file from the index can take upwards of 10 seconds due to the index expansion. After this change, it only takes ~0.3 seconds unless the file is outside of the sparse index.

Kevin Lyles (2):
  Allow using stdin in run_on_* functions
  Mark 'git cat-file' sparse-index compatible
 builtin/cat-file.c                       |  3 ++
 t/t1092-sparse-checkout-compatibility.sh | 50 +++++++++++++++++++++---
 2 files changed, 48 insertions(+), 5 deletions(-)
base-commit: 4590f2e9412378c61eac95966709c78766d326ba
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1770%2Fklylesatepic%2Fkl%2Fmark-cat-file-sparse-index-compatible-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1770/klylesatepic/kl/mark-cat-file-sparse-index-compatible-v3
Pull-Request: https://github.com/git/git/pull/1770
Range-diff vs v2:
 1:  7067a4c5da2 = 1:  b310593aec2 Allow using stdin in run_on_* functions
 2:  a92825e502f ! 2:  f4d1461b993 Mark 'git cat-file' sparse-index compatible
     @@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'advice.sparseInde
      +	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'
     ++	ensure_expanded cat-file -p :folder1/a
     ++'
      +
      +test_expect_success 'cat-file --batch' '
      +	init_repos &&
     @@ t/t1092-sparse-checkout-compatibility.sh: test_expect_success 'advice.sparseInde
      +	echo "new content" >>sparse-index/deep/a &&
      +	run_on_all git add deep/a &&
      +
     -+	echo ":deep/a">in &&
     ++	echo ":deep/a" >in &&
      +	test_all_match git cat-file --batch <in &&
      +	ensure_not_expanded cat-file --batch <in &&
      +
     -+	echo ":folder1/a">in &&
     ++	echo ":folder1/a" >in &&
      +	test_all_match git cat-file --batch <in &&
      +	ensure_expanded cat-file --batch <in &&
      +
     -+	cat <<-\EOF >in &&
     ++	cat >in <<-\EOF &&
      +	:deep/a
      +	:folder1/a
      +	EOF
      +	test_all_match git cat-file --batch <in &&
     -+	ensure_expanded cat-file --batch <in'
     ++	ensure_expanded cat-file --batch <in
     ++'
      +
       test_done
-- 
gitgitgadget
Previous: Junio C HamanoNext: Kevin Lyles via GitGitGadget
Message 8 of 17 in “Mark `cat-file` sparse-index compatible”
  1. Mark `cat-file` sparse-index compatibleKevin Lyles via GitGitGadget, Aug 26, 2024
  2. Derrick StoleeAug 29, 2024
  3. 0/2 Mark cat-file sparse-index compatibleKevin Lyles via GitGitGadget, Aug 30, 2024
  4. 1/2 Allow using stdin in run_on_* functionsKevin Lyles via GitGitGadget, Aug 30, 2024
  5. 2/2 Mark 'git cat-file' sparse-index compatibleKevin Lyles via GitGitGadget, Aug 30, 2024
  6. Derrick StoleeSep 3, 2024
  7. Junio C HamanoSep 3, 2024
  8. 0/2 Mark 'git cat-file' sparse-index compatibleKevin Lyles via GitGitGadget, Sep 3, 2024
  9. 1/2 Allow using stdin in run_on_* functionsKevin Lyles via GitGitGadget, Sep 3, 2024
  10. Junio C HamanoSep 3, 2024
  11. 2/2 Mark 'git cat-file' sparse-index compatibleKevin Lyles via GitGitGadget, Sep 3, 2024
  12. Junio C HamanoSep 3, 2024
  13. 0/2 builtin/cat-file: mark 'git cat-file' sparse-index compatibleKevin Lyles via GitGitGadget, Sep 3, 2024
  14. 1/2 t1092: allow run_on_* functions to use standard inputKevin Lyles via GitGitGadget, Sep 3, 2024
  15. Junio C HamanoSep 4, 2024
  16. 2/2 builtin/cat-file: mark 'git cat-file' sparse-index compatibleKevin Lyles via GitGitGadget, Sep 3, 2024
  17. Junio C HamanoSep 4, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.