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

Re: git sparse checkout exclusions not working?

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Apr 30, 2011, 10:06 UTC
Message-ID
<BANLkTikU_Qjs9jo2MmPdbwVNBj1V9vJJSw@mail.gmail.com>
In-Reply-To
<BANLkTi=m4hcs7pVgn0rkQktmZaqK_ORxaA@mail.gmail.com>
On Fri, Apr 29, 2011 at 7:10 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
Show 17 quoted lines
> On Wed, Apr 27, 2011 at 11:35 PM,  <skillzero@gmail.com> wrote:
>> It seems like ! patterns in the sparse-checkout file don't exclude
>> individual files in a directory. Here's what I did:
>>
>> ...
>>
>> The "test1" directory was included, but "test1/file2.txt" wasn't
>> excluded even though I added a ! pattern for it. The test2 directory
>> was correctly excluded so that makes me think sparse was working in
>> general, but just not respecting the ! pattern in this case.
>>
>> Is this a bug or am I doing something wrong?
>
> I can reproduce it too. It looks like a regression from
> whole-directory matching. If a directory is matched, all files inside
> are considered "in". Let's see if I can come up with something this
> weekend.

sparse checkout rules are not the only ones falling for this trap. .gitignore has the same problem:

pclouds@do /tmp/z $ cat .gitignore t !t/1 pclouds@do /tmp/z $ ls t 1 2 3 pclouds@do /tmp/z $ git init Initialized empty Git repository in /tmp/z/.git/ pclouds@do /tmp/z $ ~/w/git/git add . pclouds@do /tmp/z $ git ls-files .gitignore

I wonder if we can convert struct exclude to struct pathspec and solve the problem all at the same place. Granted .gitignore's '*' is different from pathspec's '*' (ie. FNM_PATHNAME vs no flag to fnmatch), but struct pathspec can be taught to do it both ways and the pathspec magic can expose FNM_PATHNAME to users too.

-- 
Duy
Previous: Nguyen Thai Ngoc Duy
Message 3 of 3 in “git sparse checkout exclusions not working?”
  1. skillzero@gmail.comApr 27, 2011
  2. Nguyen Thai Ngoc DuyApr 29, 2011
  3. Nguyen Thai Ngoc DuyApr 30, 2011

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.