Re: [PATCH v11] setup: improve error diagnosis for invalid .git files
From: Junio C Hamano <hidden>
Date: 2026-03-04 16:53:58
Tian Yuchen [off-list ref] writes:
Hi Junio and Phillip, Thanks for the detailed reply! After reading through your discussion, I believe the most crucial point is:quoted
"We were given an invalid GIT_DIR, we are not doing discovery, hence we are operating without a repository"If I understand correctly, the expected behavior should be: when a user explicitly passes 'GIT_DIR=/dev/null git diff', Git should no longer need to "search" or "guess" anything. Instead, if it's a trash file (or something similar) rather a repository, Git should simply act as if no repository exists. Is that correct?
That is one of the things. The broken test highlighted that GIT_DIR_EXPLICIT case needs more thought than what we have discussed so far, but there may be other cases that we need to also think about. See what different cases are in the big switch statement in setup_git_directory_gently().
So what I'm doing next is:quoted
All calls to read_gitfile_gently(path, NULL) need to be audited and then we need to decide which ones to leave lenient, and which ones are OK to tighten together with the call used during the repository discovery.Will be working on it in the next few days.
Thanks.