config: Add new option to open an editor.
The idea was originated by discussion about usability of manually editing the config file in 'special needs' systems such as Windows. Now the user can forget a bit about where the config files actually are. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Feb 7, 2009 at 23:53 UTC
3bec8ff99a7792cae67aaeb5892d832478d7f548
2 files changed
+18
-1
Documentation/git-config.txt
+6
@@ -22,6 +22,7 @@ SYNOPSIS
22
'git config' [<file-option>] [-z|--null] -l | --list
23
'git config' [<file-option>] --get-color name [default]
24
'git config' [<file-option>] --get-colorbool name [stdout-is-tty]
25
+'git config' [<file-option>] -e | --edit
26
27
DESCRIPTION
28
-----------
@@ -157,6 +158,11 @@ See also <<FILES>>.
158
output. The optional `default` parameter is used instead, if
159
there is no color configured for `name`.
160
161
+-e::
162
+--edit::
163
+ Opens an editor to modify the specified config file; either
164
+ '--system', '--global', or repository (default).
165
+
166
[[FILES]]
167
FILES
168
-----
builtin-config.c
+12
-1
@@ -3,7 +3,7 @@
3
#include "color.h"
4
5
static const char git_config_set_usage[] =
6
-"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
6
+"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty] | --edit | -e ]";
7
8
static char *key;
9
static regex_t *key_regexp;
@@ -362,6 +362,17 @@ int cmd_config(int argc, const char **argv, const char *prefix)
362
return get_color(argc-2, argv+2);
363
} else if (!strcmp(argv[1], "--get-colorbool")) {
364
return get_colorbool(argc-2, argv+2);
365
+ } else if (!strcmp(argv[1], "--edit") || !strcmp(argv[1], "-e")) {
366
+ const char *config_filename;
367
+ if (argc != 2)
368
+ usage(git_config_set_usage);
369
+ if (config_exclusive_filename)
370
+ config_filename = config_exclusive_filename;
371
+ else
372
+ config_filename = git_path("config");
373
+ git_config(git_default_config, NULL);
374
+ launch_editor(config_filename, NULL, NULL);
375
+ return 0;
376
} else
377
break;
378
argc--;