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

Re: git config problem with strange config files

From
Jeff King <peff@peff.net>
Date
Jan 1, 2008, 06:23 UTC
Message-ID
<20080101062314.GA21555@coredump.intra.peff.net>
In-Reply-To
<20080101061734.GA15453@coredump.intra.peff.net>
On Tue, Jan 01, 2008 at 01:17:34AM -0500, Jeff King wrote:
Show 18 quoted lines
> @@ -118,7 +119,7 @@ static int get_value(config_fn_t fn, char *name, unsigned int len)
>  	/* Get the full name */
>  	for (;;) {
>  		c = get_next_char();
> -		if (c == EOF)
> +		if (config_file_eof)
>  			break;
>  		if (!iskeychar(c))
>  			break;
> @@ -182,7 +183,7 @@ static int get_base_var(char *name)
>  
>  	for (;;) {
>  		int c = get_next_char();
> -		if (c == EOF)
> +		if (config_file_eof)
>  			return -1;
>  		if (c == ']')
>  			return baselen;

In these two hunks, we now check the eof flag correctly, which follows through on the intent of the original code. But if you look carefully at get_next_char(), it _never_ returns EOF in the first place; it replaces it with '\n' and sets an external flag. So this 'if' branch was never reached, but happened to work because the returned newline triggers a similar effect.

By actually looking at the flag, I am implementing the original intent, but it is a potential behavior change (I don't _think_ it should matter, and it passes all of the config tests, but I haven't looked carefully at all the ramifications). So it might be simpler yet to just eliminate that conditional return.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 3 of 5 in “git config problem with strange config files”
  1. Peter OberndorferDec 31, 2007
  2. Jeff KingJan 1, 2008
  3. Jeff KingJan 1, 2008
  4. Junio C HamanoJan 1, 2008
  5. Peter OberndorferJan 1, 2008

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.