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

Bug report - sparse-checkout ignores prefix when run in subdirectories

From
Lessley Dennington <lessleydennington@gmail.com>
Date
Jan 5, 2022, 20:13 UTC
Message-ID
<29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com>

Hello everyone! See the following bug report pertaining to sparse-checkout when run outside top-level directories.

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

$ git init -b main tmp $ cd tmp $ mkdir -p a/b/c $ touch a/b/c/d a/b/c/e $ git add a/ $ git commit -m "initial" $ cd a/ # Not at the top level anymore $ git sparse-checkout set --cone b/c $ git -C .. sparse-checkout list

What did you expect to happen? (Expected behavior)
We expected the output sparsity path to be a/b/c.
What happened instead? (Actual behavior)

The output was b/c. Running $ cat ../.git/info/sparse-checkout showed that the paths in this file were incorrect: /* !/*/ /b/ !/b/*/ /b/c/

What's different between what you expected and what actually happened?

The output path and the paths in the sparse-checkout file are missing the expected 'a' prefix. This means that the `set` and `add` subcommands of `sparse-checkout` can only be safely run from a repo's top-level directory.

Anything else you want to add:

This was discovered by newren@gmail.com in my recent tab-completion series. You can find additional context at [1].

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.34.1.88.gcecf501e07.dirty (local build, based off
en/sparse-checkout-set)
cpu: x86_64
shell-path: /bin/zsh
uname: Darwin
compiler info:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr
--with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$SHELL (typically, interactive shell): /bin/zsh
-Lessley

[1]: https://lore.kernel.org/git/CABPp-BGdr54XgCXw8k1xRCgkwBtDonyODS3O+_nS_QY3SOEFGQ@mail.gmail.com/

Next: Junio C Hamano
Message 1 of 10 in “Bug report - sparse-checkout ignores prefix when run in subdirectories”
  1. Lessley DenningtonJan 5, 2022
  2. Junio C HamanoJan 5, 2022
  3. Elijah NewrenJan 5, 2022
  4. Junio C HamanoJan 5, 2022
  5. Elijah NewrenJan 6, 2022
  6. Junio C HamanoJan 6, 2022
  7. Elijah NewrenJan 6, 2022
  8. Junio C HamanoJan 6, 2022
  9. Derrick StoleeJan 27, 2022
  10. Elijah NewrenJan 27, 2022

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.