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

[PATCH] config: Add new option to open an editor.

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Feb 3, 2009, 22:40 UTC
Message-ID
<1233700826-11763-1-git-send-email-felipe.contreras@gmail.com>

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>
---
 Documentation/git-config.txt |    6 ++++++
 builtin-config.c             |   11 ++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 19a8917..7d14007 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -22,6 +22,7 @@ SYNOPSIS
 'git config' [<file-option>] [-z|--null] -l | --list
 'git config' [<file-option>] --get-color name [default]
 'git config' [<file-option>] --get-colorbool name [stdout-is-tty]
+'git config' [<file-option>] -e | --edit
 
 DESCRIPTION
 -----------
@@ -157,6 +158,11 @@ See also <<FILES>>.
 	output.  The optional `default` parameter is used instead, if
 	there is no color configured for `name`.
 
+-e::
+--edit::
+	Opens an editor to modify the specified config file; either
+	'--system', '--global', or repository (default).
+
 [[FILES]]
 FILES
 -----
diff --git a/builtin-config.c b/builtin-config.c
index f710162..b0a86b1 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -3,7 +3,7 @@
 #include "color.h"
 
 static const char git_config_set_usage[] =
-"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]";
+"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 ]";
 
 static char *key;
 static regex_t *key_regexp;
@@ -362,6 +362,15 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 			return get_color(argc-2, argv+2);
 		} else if (!strcmp(argv[1], "--get-colorbool")) {
 			return get_colorbool(argc-2, argv+2);
+		} else if (!strcmp(argv[1], "--edit") || !strcmp(argv[1], "-e")) {
+			char *config_filename;
+			if (config_exclusive_filename)
+				config_filename = xstrdup(config_exclusive_filename);
+			else
+				config_filename = git_pathdup("config");
+			launch_editor(config_filename, NULL, NULL);
+			free(config_filename);
+			return 0;
 		} else
 			break;
 		argc--;
-- 
1.6.1.2
Next: Johannes Schindelin
Message 1 of 25 in “config: Add new option to open an editor.”
  1. config: Add new option to open an editor.Felipe Contreras, Feb 3, 2009
  2. Johannes SchindelinFeb 3, 2009
  3. Felipe ContrerasFeb 3, 2009
  4. Johannes SchindelinFeb 3, 2009
  5. Felipe ContrerasFeb 3, 2009
  6. config: Add new option to open an editor.Felipe Contreras, Feb 3, 2009
  7. Johannes SchindelinFeb 3, 2009
  8. Felipe ContrerasFeb 3, 2009
  9. Jeff KingFeb 4, 2009
  10. Felipe ContrerasFeb 4, 2009
  11. Jeff KingFeb 4, 2009
  12. Felipe ContrerasFeb 4, 2009
  13. config: Add new option to open an editor.Felipe Contreras, Feb 4, 2009
  14. Junio C HamanoFeb 4, 2009
  15. Felipe ContrerasFeb 4, 2009
  16. Johannes SchindelinFeb 4, 2009
  17. Johannes SchindelinFeb 4, 2009
  18. Felipe ContrerasFeb 7, 2009
  19. Johannes SchindelinFeb 7, 2009
  20. Felipe ContrerasFeb 7, 2009
  21. Junio C HamanoFeb 7, 2009
  22. Felipe ContrerasFeb 7, 2009
  23. config: Add new option to open an editor.Felipe Contreras, Feb 7, 2009
  24. Johannes SchindelinFeb 4, 2009
  25. Felipe ContrerasFeb 4, 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.