Re: [PATCH 1/7] read info/{attributes,exclude} only when in repository
From: Jeff King <hidden>
Date: 2016-10-25 14:57:20
On Tue, Oct 25, 2016 at 07:24:50PM +0700, Duy Nguyen wrote:
quoted
Let's detect this situation explicitly and skip reading the file (i.e., the same behavior we'd get if we were in a repository and the file did not exist).On the other hand, if we invoke attr machinery too early by mistake, before setup_git_directory* is called, then we skip .git/info/attributes file as well even though I think we should shout "call setup_git_directory first!" so the developer can fix it.
I wonder if we should have two flags in startup_info to say "yes setup_git_dir... has been called, you can trust startup_info->have_repository" and "yes, i do not call setup_git_dir on purpose, quit complaining" then we could still catch unintended .git/info/attributes ignore while letting git grep --no-index work correctly.
Yeah, it would be nice for the low-level code to be able to detect such errors. I don't mind if you want to extend startup_info in that way, but it will probably introduce a period of instability and regressions (sites that are perfectly fine, but forgot to set the "I know what I'm doing" flag). -Peff