Re: [PATCH v11] setup: improve error diagnosis for invalid .git files

2 messages, 2 authors, 2026-03-04 · open the first message on its own page

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.

Re: [PATCH v11] setup: improve error diagnosis for invalid .git files

From: Tian Yuchen <hidden>
Date: 2026-03-04 17:35:15

Hi Junio,
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().
Shortly before your email I had already sent the v12 patch.

I did make changes in setup_git_directory_gently_1(), and logically it 
shouldn't cause major issues.

Unfortunately, looking back now, my implementation barely qualifies as 
“functional” and actually undermines the purpose of setup_git..() 
itself. It's a mess — I rushed into it without properly reviewing the 
context (like how other cases are handled) :(((

I'll polish it thoroughly before releasing v13.

Regards,

Yuchen
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help