git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] read_gitfile_gently(): return non-repo path on error

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2026, 13:01 UTC
Message-ID
<xmqqeciezh0w.fsf@gitster.g>
In-Reply-To
<ah6WEtk2pXyViEQA@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 15 quoted lines
> On Tue, Jun 02, 2026 at 02:11:59AM -0400, Jeff King wrote:
> [snip]
>> Two other points of interest.
>> 
>> One, I'm not sure how useful printing the pointed-to directory is. We
>> _could_ just say:
>> 
>>   fatal: gitfile does not point to a valid repository: /path/to/.git
>> 
>> which is enough for somebody to investigate themselves. That would
>> certainly make the patch smaller.
>
> I have to agree that the patch is somewhat gross, and I myself don't
> really see much of an issue to move to an error message like the above
> if it ends up simplifying the logic.

So we are in agreement among three of us that simplifying the code to lose error message with dubious value would be a good way forward.

Peff, can we have a formal [v2] then?
Show 17 quoted lines
>> diff --git a/setup.c b/setup.c
>> index 075bf89fa9..2df6fbf595 100644
>> --- a/setup.c
>> +++ b/setup.c
>> @@ -1641,9 +1650,11 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
>>  					return GIT_DIR_INVALID_GITFILE;
>>  			default:
>>  				if (die_on_error)
>> -					read_gitfile_error_die(error_code, dir->buf, NULL);
>> -				else
>> +					read_gitfile_error_die(error_code, dir->buf, error_dst);
>> +				else {
>> +					free(error_dst);
>>  					return GIT_DIR_INVALID_GITFILE;
>> +				}
>
> The `if` branch should also gain some curly braces here.
True.
Thanks.
Previous: Patrick SteinhardtNext: Jeff King
Message 7 of 12 in “read_gitfile_gently(): return non-repo path on error”
  1. read_gitfile_gently(): return non-repo path on errorJeff King, Jun 2, 2026
  2. Junio C HamanoJun 2, 2026
  3. Jeff KingJun 2, 2026
  4. Patrick SteinhardtJun 2, 2026
  5. Jeff KingJun 4, 2026
  6. Patrick SteinhardtJun 4, 2026
  7. Junio C HamanoJun 10, 2026
  8. read_gitfile(): simplify NOT_A_REPO error messageJeff King, Jun 16, 2026
  9. read_gitfile(): simplify NOT_A_REPO error messageJeff King, Jun 16, 2026
  10. Junio C HamanoJun 16, 2026
  11. Jeff KingJun 16, 2026
  12. Junio C HamanoJun 16, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.