From: Nguyen Thai Ngoc Duy Date: Sat, 09 Apr 2011 05:05:45 GMT Subject: Re: [PATCH 2/4] add -u: get rid of "treewideupdate" configuration Message-ID: In-Reply-To: <7v39ls10q6.fsf@alter.siamese.dyndns.org> On Sat, Apr 9, 2011 at 11:56 AM, Junio C Hamano wrote: > Instead, when we refactor get/init-pathspec API, we could expose an > interface to turn one element from argv[] into a "struct pathspec_item". > Then we can try to feed argv[i] to that string-to-pathspec_item function, > and consider that argv[i] _is_ a proper pathspec only if it parses > correctly *and* if it matches either an item in the current working tree. > > That would be a moral equivalent of the current verify_filename() check > but is far more precise one; e.g. the current code rejects > >        git grep -e foo '*.c' ;# bad > > because '*.c' is not an object name, but lstat("*.c") fails, and you need > to disambiguate with '--'.  If you rewrite the verify_filename() in the > way I outlined above, you wouldn't have to. I considered that, but we may need to go through the whole worktree just to verify "*.c" matches something. The worst case scenario can be expensive (eg. doing that on a-forest-with-no-c-file gentoo-x86.git). Alternative approach is recognize "*.c" has wildcard and let it pass without actually matching. -- Duy