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

Possible regression for sparse-checkout in git 2.27.0

From
SCShaun Case <warmsocks@gmail.com>
Date
Jun 3, 2020, 01:08 UTC
Message-ID
<CAD3+_6CUX0RPr-dgfUnfGDNNfqu80SYCskioYnu=MS6aJv2dEQ@mail.gmail.com>

I'm seeing an unexpected change in behavior of git sparse-checkout between 2.26.2 and 2.27.0 on CentOS 7.8. Problem manifests with both github and multiple recent versions of gitlab.

Sources came from https://mirrors.edge.kernel.org/pub/software/scm/git/, I verified the sha256 hashes for both 2.26.2 and 2.27.0 matched.

Built with gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)

By doing:
./configure \
    --prefix=/usr/local \
    --with-python=python3
make -j 10
sudo make -j 10 install install-doc install-html
Problem detail:
In 2.26.2, git sparse-checkout commands...
  init --cone
  set
  add

... all bring in files. In 2.27.0, no files appear except the .git subdir until I do:

git read-tree -mu HEAD

However, according to my reading of this, git read-tree should not be necessary in 2.27.0: https://stackoverflow.com/questions/28760940/why-does-one-call-git-read-tree-after-a-sparse-checkout/

When I do export GIT_TRACE_PACKET=1, I see that the init --cone, set and add sparse-checkout commands all talk to the server. In 2.27.0, these commands do not result in any packets sent to the server. It sounds like they should be calling update_sparsity() themselves, but aren't. Is that wrong? I couldn't find a git CLI client command to invoke it directly except for read-tree.

Below is a small bash script and its output that shows the problem with a small random public repo on github.

Best regards, Shaun

Script: ============================================== #!/bin/bash -x

export GIT_TRACE_PACKET=0 git --version git clone --filter=blob:none --no-checkout https://github.com/r-spacex/launch-timeline.git cd launch-timeline

# Note no server traffic at from here... export GIT_TRACE_PACKET=1 git sparse-checkout init --cone git sparse-checkout set README.md git sparse-checkout add css # ... to here.

# There is nothing here yet except .git/ ls -las

# This brings in the files as expected, uncomment to verify. # git read-tree -mu HEAD ==============================================

Output:
==============================================
3sc3396:/tmp>demo-git-sparse-checkout-bug.sh
+ export GIT_TRACE_PACKET=0
+ GIT_TRACE_PACKET=0
+ git --version
git version 2.27.0
+ git clone --filter=blob:none --no-checkout
https://github.com/r-spacex/launch-timeline.git
Cloning into 'launch-timeline'...
remote: Enumerating objects: 529, done.
remote: Total 529 (delta 0), reused 0 (delta 0), pack-reused 529
Receiving objects: 100% (529/529), 67.49 KiB | 987.00 KiB/s, done.
Resolving deltas: 100% (168/168), done.
+ cd launch-timeline
+ export GIT_TRACE_PACKET=1
+ GIT_TRACE_PACKET=1
+ git sparse-checkout init --cone
+ git sparse-checkout set README.md
+ git sparse-checkout add css
+ ls -las
total 68
 4 drwxrwxr-x   3 scase scase  4096 Jun  2 17:46 .
60 drwxrwxrwt. 34 root  root  57344 Jun  2 17:46 ..
 4 drwxrwxr-x   8 scase scase  4096 Jun  2 17:46 .git
==============================================
Next: Elijah Newren
Message 1 of 8 in “Possible regression for sparse-checkout in git 2.27.0”
  1. Shaun CaseJun 3, 2020
  2. Elijah NewrenJun 3, 2020
  3. Derrick StoleeJun 3, 2020
  4. Elijah NewrenJun 4, 2020
  5. Shaun CaseJun 4, 2020
  6. Derrick StoleeJun 5, 2020
  7. Junio C HamanoJun 5, 2020
  8. Derrick StoleeJun 5, 2020

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.