Re: [RFC PATCH v3 7/8] Support sparse checkout in unpack_trees() and read-tree
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Aug 12, 2009, 01:30 UTC
- Message-ID
- <fcaeb9bf0908111830n50bd4733h5033c6f13a45999@mail.gmail.com>
- In-Reply-To
- <2729632a0908111503i7f035c1aw4e84151eab821006@mail.gmail.com>
On Wed, Aug 12, 2009 at 5:03 AM, <skillzero@gmail.com> wrote:
Show 24 quoted lines
> On Tue, Aug 11, 2009 at 2:38 PM, Jakub Narebski<jnareb@gmail.com> wrote: >> skillzero@gmail.com writes: >>> 2009/8/11 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>: >> >>> > [1] .git/info/sparse has the same syntax as .git/info/exclude. Files >>> > that match the patterns will be set as CE_VALID. >>> >>> Does this mean it will only support excluding paths you don't want >>> rather than letting you only include paths you do want? >> >> Errr... what I read is that paths set by .git/info/sparse would be >> excluded from checkout (marked as assume-unchanged / CE_VALID). >> >> But if it is the same mechanism as gitignore, then you can use ! >> prefix to set files (patterns) to include, e.g. >> >> !Documentation/ >> * >> >> (I think rules are processed top-down, first matching wins). > > I wasn't sure because the .gitignore negation stuff mentions negating > a previously ignored pattern. But for sparse patterns, there likely > wouldn't be a previous pattern.
No problem. We put pattern '*' at top (match everything). Previous pattern issue solved.
Show 5 quoted lines
> Include patterns are a little > different in that if there are no include patterns (but maybe some > exclude patterns), I think the expectation is that everything will be > included (minus excludes), but if you have some include patterns then > only those paths will be included (minus any excludes).
Let's say you want to include foo/ and bar/ only, this should work:
* !foo/ !bar/
The evaluating order is from bottom up. When it first matches 'bar/', because it a negate pattern, it returns "no don't match" and stops. When it matches neither foo/ nor bar/ then it will be caught by '*' and return "yes it matches" - that means "ignored" from checkout area. In the end only foo/* and bar/* survive.
I think it's as easy as writing exclude patterns once you figure out '*'.
-- Duy