From: Christian Couder Date: Mon, 29 Jun 2026 06:03:40 GMT Subject: Re: [PATCH v4 1/1] environment: move excludes_file into repo_config_values Message-ID: In-Reply-To: <18ad7c1c-5ddc-4f62-ba7c-5cda53f5a48d@malon.dev> On Sun, Jun 28, 2026 at 2:58 PM Tian Yuchen wrote: > > On 6/28/26 16:40, Junio C Hamano wrote: > > Tian Yuchen writes: > > > >>> Wouldn't we rather want to try to be more strict and say > >>> > >>> if (!repo || !repo->initialized) > >>> BUG("repo must be an initialied repository"); > >>> > >>> here? Aren't all the callers of this function supposed to be > >>> dealing with an already initialized repository? > >> > >> That makes sense, but from my point of view... > >> > >> 'repo_config_values()' already has a check for 'repo->initialized'. If > >> we're absolutely certain that the 'repo' is initialized, wouldn't it be > >> better to simply remove all the checks inside the getter and leave the > >> judgment to 'repo_config_values()'? > > > > Yes, that was what I was getting at ;-). > > A lot of CI tests are failing, but that just goes to show that the > "bugs" are being properly identified, doesn’t it? > > It means there are a lot of "invalid" calls in the tests (if the way we > define a 'valid' call, i.e. repo must be initialized, is correct)... It > seems that code like 'if (repo != the_repository) return' or something > similar is inevitably going to end up somewhere, even though, as you > said, it’s "sweeping problems under the rug." > > I’m not sure how to proceed from here either.. I agree that the best end state would be to have no `if (!repo || !repo->initialized)` check, but we shouldn't have to get there right away. I think it's fine to proceed in several steps: 1) `if (!repo || !repo->initialized) return NULL;` allows us to remove the global variable and use getters which will help us in the next step. 2) `if (!repo || !repo->initialized) return BUG("repo must be an initialized repository");` now we want to find and fix callers (including tests) that haven't properly initialized things. 3) No `if (!repo || !repo->initialized)` check, as we are sure that all the callers that didn't properly initialized things have been found and fixed. So I think 1) is fine for now as long as we properly explain in the commit messages and in code comments (maybe using NEEDSWORK comments) that we know there is more work to do on this in the future.