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

Re: git config --help not functional on bad config

From
Jeff King <peff@peff.net>
Date
Jul 11, 2017, 17:53 UTC
Message-ID
<20170711175342.mllx7efdsqlzv5lo@sigill.intra.peff.net>
In-Reply-To
<alpine.DEB.2.00.1707111541150.18163@ds9.cixit.se>
On Tue, Jul 11, 2017 at 03:49:21PM +0100, Peter Krefting wrote:
Show 8 quoted lines
> That's fine. However, when trying to look for help, it is not that useful:
> 
>   $ git config --help
>   error: malformed value for branch.autosetuprebase
>   fatal: bad config variable 'branch.autosetuprebase' in file '.git/config' at line 24
> 
> Perhaps it should allow "--help" to go through even if the configuration is
> bad?

Yes, I agree the current behavior is poor. What's happening under the hood is that "--help" for any command runs "git help config", which in turn looks at the config to pick up things like help.format.

But it also loads git_default_config(), which I suspect isn't actually useful. It goes all the way back to 70087cdbd (git-help: add "help.format" config variable., 2007-12-15), and it looks like it was probably added just to match other config callbacks.

So I think we could probably just do this:
diff --git a/builtin/help.c b/builtin/help.c
index 334a8494a..c42dfc9e9 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -273,7 +273,7 @@ static int git_help_config(const char *var, const char *value, void *cb)
 	if (starts_with(var, "man."))
 		return add_man_viewer_info(var, value);
 
-	return git_default_config(var, value, cb);
+	return 0;
 }
 
 static struct cmdnames main_cmds, other_cmds;

which makes your case work.

-Peff
Previous: Peter KreftingNext: Stefan Beller
Message 2 of 6 in “git config --help not functional on bad config”
  1. Peter KreftingJul 11, 2017
  2. Jeff KingJul 11, 2017
  3. Stefan BellerJul 11, 2017
  4. Jeff KingJul 11, 2017
  5. Stefan BellerJul 11, 2017
  6. Jeff KingJul 11, 2017

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.