@matheusbsbs / matheus-bagliano / commits / b408457f2e
Fork 0

git config: trivial rename in preparation for parseopt

Essentially 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Feb 21, 2009 at 02:48 UTC b408457f2e167aaf8e7a087b374357f4a74e9680
1 file changed +18 -14
builtin-config.c
+18 -14
@@ -178,6 +178,7 @@ static char *normalize_value(const char *key, const char *value)
178
179 static int get_color_found;
180 static const char *get_color_slot;
181 +static const char *get_colorbool_slot;
182 static char parsed_color[COLOR_MAXLEN];
183
184 static int git_get_color_config(const char *var, const char *value, void *cb)
@@ -231,7 +232,7 @@ static int get_diff_color_found;
232 static int git_get_colorbool_config(const char *var, const char *value,
233 void *cb)
234 {
234 - if (!strcmp(var, get_color_slot)) {
235 + if (!strcmp(var, get_colorbool_slot)) {
236 get_colorbool_found =
237 git_config_colorbool(var, value, stdout_is_tty);
238 }
@@ -263,11 +264,11 @@ static int get_colorbool(int argc, const char **argv)
264 usage(git_config_set_usage);
265 get_colorbool_found = -1;
266 get_diff_color_found = -1;
266 - get_color_slot = argv[0];
267 + get_colorbool_slot = argv[0];
268 git_config(git_get_colorbool_config, NULL);
269
270 if (get_colorbool_found < 0) {
270 - if (!strcmp(get_color_slot, "color.diff"))
271 + if (!strcmp(get_colorbool_slot, "color.diff"))
272 get_colorbool_found = get_diff_color_found;
273 if (get_colorbool_found < 0)
274 get_colorbool_found = git_use_color_default;
@@ -281,11 +282,11 @@ static int get_colorbool(int argc, const char **argv)
282 }
283 }
284
284 -int cmd_config(int argc, const char **argv, const char *prefix)
285 +int cmd_config(int argc, const char **argv, const char *unused_prefix)
286 {
287 int nongit;
288 char *value;
288 - const char *file = setup_git_directory_gently(&nongit);
289 + const char *prefix = setup_git_directory_gently(&nongit);
290
291 config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
292
@@ -299,10 +300,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
300 else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) {
301 if (argc != 2)
302 usage(git_config_set_usage);
302 - if (git_config(show_all_config, NULL) < 0 &&
303 - file && errno)
304 - die("unable to read config file %s: %s", file,
305 - strerror(errno));
303 + if (git_config(show_all_config, NULL) < 0) {
304 + if (config_exclusive_filename)
305 + die("unable to read config file %s: %s",
306 + config_exclusive_filename, strerror(errno));
307 + else
308 + die("error processing config file(s)");
309 + }
310 return 0;
311 }
312 else if (!strcmp(argv[1], "--global")) {
@@ -319,12 +323,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
323 else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
324 if (argc < 3)
325 usage(git_config_set_usage);
322 - if (!is_absolute_path(argv[2]) && file)
323 - file = prefix_filename(file, strlen(file),
324 - argv[2]);
326 + if (!is_absolute_path(argv[2]) && prefix)
327 + config_exclusive_filename = prefix_filename(prefix,
328 + strlen(prefix),
329 + argv[2]);
330 else
326 - file = argv[2];
327 - config_exclusive_filename = file;
331 + config_exclusive_filename = argv[2];
332 argc--;
333 argv++;
334 }