Re: [PATCH v9] setup: improve error diagnosis for invalid .git files
- From
Tian Yuchen <a3205153416@gmail.com>
- Date
- Feb 22, 2026, 10:28 UTC
- Message-ID
- <9d79bff0-eb97-4332-8260-236761c9c3da@gmail.com>
- In-Reply-To
- <xmqqseatqqpr.fsf@gitster.g>
Hi Junio,
On 2/22/26 13:42, Junio C Hamano wrote:
> The changes to these two functions require us to audit callers of > them that are outside the call graph of the main focus of this > patch. For example, we see the following code in submodule.c:
Oops, I was so focused on setup.c that I completely overlooked the external callers of the API. Thank you for pointing out!
I ran git grep for READ_GITFILE_ERR_STAT_FAILED and READ_GITFILE_ERR_NOT_A_FILE across the tree and audited the hits. Besides the expected changes in setup.c, here is what I found and fixed:
- In submodule.c, exactly as you pointed out. - In worktree.c there were two places relying on NOT_A_FILE to print the specific ".git is not a file" error. I added READ_GITFILE_ERR_IS_A_DIR to those conditions to prevent the error from degrading to the generic ".git file broken".
I have also added the NEEDSWORK comment in the switch statedment, as you mentioned earlier.
Thanks,
Yuchen