git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/8] config: Trivial rename in preparation for parseopt.
@ 2009-02-17  0:54 Felipe Contreras
  2009-02-17  0:54 ` [PATCH v2 2/8] config: Reorganize get_color* Felipe Contreras
  2009-02-17  1:45 ` [PATCH v2 1/8] config: Trivial rename in preparation for parseopt Junio C Hamano
  0 siblings, 2 replies; 24+ messages in thread
From: Felipe Contreras @ 2009-02-17  0:54 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Junio C Hamano, Felipe Contreras

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 |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/builtin-config.c b/builtin-config.c
index 6937eaf..da754e0 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,8 @@ 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)
+				die("error processing config file(s)");
 			return 0;
 		}
 		else if (!strcmp(argv[1], "--global")) {
@@ -319,12 +318,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

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2009-02-17 14:01 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17  0:54 [PATCH v2 1/8] config: Trivial rename in preparation for parseopt Felipe Contreras
2009-02-17  0:54 ` [PATCH v2 2/8] config: Reorganize get_color* Felipe Contreras
2009-02-17  0:54   ` [PATCH v2 3/8] config: Use parseopt Felipe Contreras
2009-02-17  0:54     ` [PATCH v2 4/8] config: Disallow multiple variable types Felipe Contreras
2009-02-17  0:54       ` [PATCH v2 5/8] config: Disallow multiple config file locations Felipe Contreras
2009-02-17  0:54         ` [PATCH v2 6/8] config: Don't allow extra arguments for -e or -l Felipe Contreras
2009-02-17  0:54           ` [PATCH v2 7/8] config: Codestyle cleanups Felipe Contreras
2009-02-17  0:54             ` [PATCH v2 8/8] config: Cleanup editor action Felipe Contreras
2009-02-17  2:28               ` Junio C Hamano
2009-02-17  2:24       ` [PATCH v2 4/8] config: Disallow multiple variable types Junio C Hamano
2009-02-17  2:24     ` [PATCH v2 3/8] config: Use parseopt Junio C Hamano
2009-02-17 13:55       ` Felipe Contreras
2009-02-17  5:44     ` Junio C Hamano
2009-02-17 10:35       ` Felipe Contreras
2009-02-17 11:55         ` Johannes Schindelin
2009-02-17 13:21           ` Felipe Contreras
2009-02-17  1:00   ` [PATCH v2 2/8] config: Reorganize get_color* Felipe Contreras
2009-02-17  2:24   ` Junio C Hamano
2009-02-17  1:45 ` [PATCH v2 1/8] config: Trivial rename in preparation for parseopt Junio C Hamano
2009-02-17  2:42   ` Felipe Contreras
2009-02-17 12:01     ` Johannes Schindelin
2009-02-17 13:59       ` Felipe Contreras
2009-02-17  9:00   ` Gerrit Pape
2009-02-17 11:58     ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).