On Tue, Aug 17, 2021 at 6:23 AM Derrick Stolee via GitGitGadget <gitgitgadget@xxxxxxxxx> wrote: > > From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> > > Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> > --- > attr.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/attr.c b/attr.c > index d029e681f28..a1009f78029 100644 > --- a/attr.c > +++ b/attr.c > @@ -14,6 +14,7 @@ > #include "utf8.h" > #include "quote.h" > #include "thread-utils.h" > +#include "dir.h" > > const char git_attr__true[] = "(builtin)true"; > const char git_attr__false[] = "\0(builtin)false"; > @@ -744,6 +745,19 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate, > if (!istate) > return NULL; > > + /* > + * In the case of cone-mode sparse-checkout, getting the > + * .gitattributes file from a directory is meaningless: all > + * contained paths will be sparse if the .gitattributes is also > + * sparse. In the case of a sparse index, it is critical that we > + * don't go looking for one as it will expand the index. > + */ "all contained paths will be sparse if the .gitattributes is also sparse"? Do you mean something more like "the .gitattributes only applies for files under the given directory, and if the directory is sparse, then neither the .gitattributes file or any other file under that directory will be present" ? Also, out of curiosity, I was suggesting in the past we do something like this for .gitignore files, for the same reason. Do we have such logic in place, or is that another area of the code that hasn't been handled yet? > + init_sparse_checkout_patterns(istate); > + if (istate->sparse_checkout_patterns && > + istate->sparse_checkout_patterns->use_cone_patterns && > + path_in_sparse_checkout(path, istate) == NOT_MATCHED) > + return NULL; > + > buf = read_blob_data_from_index(istate, path, NULL); > if (!buf) > return NULL; > -- > gitgitgadget Though the code appears correct, I too am curious about the questions Dscho asked about the code in this patch.