From: Chris Packham Date: Fri, 15 Oct 2010 23:26:42 GMT Subject: [RFC/PATCHv2 3/5] grep_cache: check pathspec first Message-ID: <1287185204-843-4-git-send-email-judge.packham@gmail.com> In-Reply-To: <1287185204-843-1-git-send-email-judge.packham@gmail.com> This makes grep_cache consistent with grep_tree. Signed-off-by: Chris Packham --- In addition to consistency, moving the pathspec check up allows the addition of a simple if clause for submodules later. builtin/grep.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index a51eb2c..251c4e7 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -595,10 +595,10 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached) for (nr = 0; nr < active_nr; nr++) { struct cache_entry *ce = active_cache[nr]; - if (!S_ISREG(ce->ce_mode)) - continue; if (!pathspec_matches(paths, ce->name, opt->max_depth)) continue; + if (!S_ISREG(ce->ce_mode)) + continue; /* * If CE_VALID is on, we assume worktree file and its cache entry * are identical, even if worktree file has been modified, so use -- 1.7.3.1