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

[PATCH] git-config: respect other options after -l, most notably --file

From
Gerrit Pape <pape@smarden.org>
Date
Oct 9, 2007, 12:50 UTC
Message-ID
<20071009125024.1259.qmail@d8e601127fe8d0.315fe32.mid.smarden.org>

When git-commit is seeing the -l|--list option, it stops reading the following command line options. So although they should be the same, the following commands act differently:

 git config --file ../repo2/.git/config -l
 git config -l --file ../repo2/.git/config

This patch delays the 'list all variables' to after the command line options have been processed.

The problem was noticed by Joey Hess, reported through
 http://bugs.debian.org/445208
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 builtin-config.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin-config.c b/builtin-config.c
index c2708ba..1bb0ebb 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -8,6 +8,7 @@ static char *key;
 static regex_t *key_regexp;
 static regex_t *regexp;
 static int show_keys;
+static int show_all;
 static int use_key_regexp;
 static int do_all;
 static int do_not_match;
@@ -173,7 +174,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 		else if (!strcmp(argv[1], "--bool"))
 			type = T_BOOL;
 		else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
-			return git_config(show_all_config);
+			show_all = 1;
 		else if (!strcmp(argv[1], "--global")) {
 			char *home = getenv("HOME");
 			if (home) {
@@ -234,6 +235,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 		argv++;
 	}
 
+	if (show_all)
+		return git_config(show_all_config);
 	switch (argc) {
 	case 2:
 		return get_value(argv[1], NULL);
-- 
1.5.3.4
Next: Johannes Schindelin
Message 1 of 4 in “git-config: respect other options after -l, most notably --file”
  1. git-config: respect other options after -l, most notably --fileGerrit Pape, Oct 9, 2007
  2. Johannes SchindelinOct 9, 2007
  3. Frank LichtenheldOct 9, 2007
  4. git-config: respect other options after -l, most notably --fileGerrit Pape, Oct 12, 2007

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.