On Mon, May 28, 2012 at 1:14 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > Actually I was referring to the exclude_stack. > > Suppose you have .gitignore file at the top that lists /foo/bar/*.c > (among other millions of patterns anchored to specific directory), > and another in the foo/bar directory. When you are looking at a > path in the top-level, currently the exclude_stack would have one > element, per-directory one for .gitignore at the top, that has > millions of patterns that would never match. And then when you > descend into foo/bar directory, prep_exclude would link two elements > (one for foo/ directory which may be empty, another for foo/bar > directory) to this, and then you check paths you see in foo/bar > directory using all the elements that appear in the exclude_stack. > > What I was suggesting was that you could choose not to add > /foo/bar/*.c entry in the exclude_stack element for the top-level > (but remember you did so), and then inside prep_exclude() when you > look at different directory, e.g. foo/bar, notice that higher level > (i.e. toplevel in this example) has such a deferred patterns that > applies to the new directory. Then instead of adding /foo/bar/*.c > at the top-level, you can pretend as if /*.c appeared in .gitignore > file in the deeper level in the hierarchy. > > And this does not happen per path you check; exclude_stack used by > excluded() is designed to take advantage of the access pattern that > we tend to check paths from the same directory together, so such an > adjustment will be per directory switching (i.e. it will be part of > the prep_exclude() overhead that is amortized over paths you walk). That's perhaps a better approach. Two points (for myself to think again after work): - that involves reordering the stack to make sure we always have gitignore "files" in root dir first, then 1st level... after we split some patterns from top-level file to deeper level, so that popping works without major change - the implication due to pattern reordering (probably keep the order as we currently have. Suppose we checking in "sub", then sub/... patterns from top-level go first, then from sub/.gitignore) -- Duy -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html