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

[PATCH v3 04/10] config: Trivial rename in preparation for parseopt.

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Feb 17, 2009, 13:52 UTC
Message-ID
<1234878776-13250-4-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1234878776-13250-3-git-send-email-felipe.contreras@gmail.com>

Essensially this replaces 'file' with 'prefix' in the cases where the variable is used as a prefix, which is consistent with other git commands.

When using the --list option general errors where not properly reported, only errors related with the 'file'. Now they are reported, and 'file' is irrelevant.

That reduces the rest of 'file' usage to nothing, therefore now only 'prefix' remains.

Suggested by Johannes Schindelin.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin-config.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/builtin-config.c b/builtin-config.c
index d52a057..5074c61 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -178,6 +178,7 @@ static char *normalize_value(const char *key, const char *value)
 
 static int get_color_found;
 static const char *get_color_slot;
+static const char *get_colorbool_slot;
 static char parsed_color[COLOR_MAXLEN];
 
 static int git_get_color_config(const char *var, const char *value, void *cb)
@@ -231,7 +232,7 @@ static int get_diff_color_found;
 static int git_get_colorbool_config(const char *var, const char *value,
 		void *cb)
 {
-	if (!strcmp(var, get_color_slot)) {
+	if (!strcmp(var, get_colorbool_slot)) {
 		get_colorbool_found =
 			git_config_colorbool(var, value, stdout_is_tty);
 	}
@@ -263,11 +264,11 @@ static int get_colorbool(int argc, const char **argv)
 		usage(git_config_set_usage);
 	get_colorbool_found = -1;
 	get_diff_color_found = -1;
-	get_color_slot = argv[0];
+	get_colorbool_slot = argv[0];
 	git_config(git_get_colorbool_config, NULL);
 
 	if (get_colorbool_found < 0) {
-		if (!strcmp(get_color_slot, "color.diff"))
+		if (!strcmp(get_colorbool_slot, "color.diff"))
 			get_colorbool_found = get_diff_color_found;
 		if (get_colorbool_found < 0)
 			get_colorbool_found = git_use_color_default;
@@ -281,11 +282,11 @@ static int get_colorbool(int argc, const char **argv)
 	}
 }
 
-int cmd_config(int argc, const char **argv, const char *prefix)
+int cmd_config(int argc, const char **argv, const char *unused_prefix)
 {
 	int nongit;
 	char *value;
-	const char *file = setup_git_directory_gently(&nongit);
+	const char *prefix = setup_git_directory_gently(&nongit);
 
 	config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
 
@@ -299,10 +300,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 		else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) {
 			if (argc != 2)
 				usage(git_config_set_usage);
-			if (git_config(show_all_config, NULL) < 0 &&
-					file && errno)
-				die("unable to read config file %s: %s", file,
-				    strerror(errno));
+			if (git_config(show_all_config, NULL) < 0) {
+				if (config_exclusive_filename)
+					die("unable to read config file %s: %s",
+					    config_exclusive_filename, strerror(errno));
+				else
+					die("error processing config file(s)");
+			}
 			return 0;
 		}
 		else if (!strcmp(argv[1], "--global")) {
@@ -319,12 +323,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 		else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
 			if (argc < 3)
 				usage(git_config_set_usage);
-			if (!is_absolute_path(argv[2]) && file)
-				file = prefix_filename(file, strlen(file),
-						       argv[2]);
+			if (!is_absolute_path(argv[2]) && prefix)
+				config_exclusive_filename = prefix_filename(prefix,
+									    strlen(prefix),
+									    argv[2]);
 			else
-				file = argv[2];
-			config_exclusive_filename = file;
+				config_exclusive_filename = argv[2];
 			argc--;
 			argv++;
 		}
-- 
1.6.1.3
Previous: Felipe ContrerasNext: Felipe Contreras
Message 4 of 16 in “config: Codestyle cleanups.”
  1. 01/10 config: Codestyle cleanups.Felipe Contreras, Feb 17, 2009
  2. 02/10 config: Cleanup editor action.Felipe Contreras, Feb 17, 2009
  3. 03/10 config: Make git_config() more flexible.Felipe Contreras, Feb 17, 2009
  4. 04/10 config: Trivial rename in preparation for parseopt.Felipe Contreras, Feb 17, 2009
  5. 05/10 config: Reorganize get_color*.Felipe Contreras, Feb 17, 2009
  6. 06/10 config: Use parseopt.Felipe Contreras, Feb 17, 2009
  7. 07/10 config: Disallow --getcolor* and other actions.Felipe Contreras, Feb 17, 2009
  8. 08/10 config: Disallow multiple config file locations.Felipe Contreras, Feb 17, 2009
  9. 09/10 config: Disallow multiple variable types.Felipe Contreras, Feb 17, 2009
  10. 10/10 config: Don't allow extra arguments for -e or -l.Felipe Contreras, Feb 17, 2009
  11. Junio C HamanoFeb 18, 2009
  12. Felipe ContrerasFeb 18, 2009
  13. Junio C HamanoFeb 18, 2009
  14. Sverre RabbelierFeb 17, 2009
  15. Felipe ContrerasFeb 18, 2009
  16. Junio C HamanoFeb 18, 2009

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.