mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'fc/config-editor'
* fc/config-editor: git config: trivial cleanup for editor action git config: codestyle cleanups config: Add new option to open an editor.
This commit is contained in:
commit
1ef87e0bb5
|
@ -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
|
||||
-----
|
||||
|
|
|
@ -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;
|
||||
|
@ -27,7 +27,7 @@ static int show_all_config(const char *key_, const char *value_, void *cb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int show_config(const char* key_, const char* value_, void *cb)
|
||||
static int show_config(const char *key_, const char *value_, void *cb)
|
||||
{
|
||||
char value[256];
|
||||
const char *vptr = value;
|
||||
|
@ -74,7 +74,7 @@ static int show_config(const char* key_, const char* value_, void *cb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_value(const char* key_, const char* regex_)
|
||||
static int get_value(const char *key_, const char *regex_)
|
||||
{
|
||||
int ret = -1;
|
||||
char *tl;
|
||||
|
@ -284,7 +284,7 @@ static int get_colorbool(int argc, const char **argv)
|
|||
int cmd_config(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int nongit;
|
||||
char* value;
|
||||
char *value;
|
||||
const char *file = setup_git_directory_gently(&nongit);
|
||||
|
||||
config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
|
||||
|
@ -362,6 +362,14 @@ 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")) {
|
||||
if (argc != 2)
|
||||
usage(git_config_set_usage);
|
||||
git_config(git_default_config, NULL);
|
||||
launch_editor(config_exclusive_filename ?
|
||||
config_exclusive_filename : git_path("config"),
|
||||
NULL, NULL);
|
||||
return 0;
|
||||
} else
|
||||
break;
|
||||
argc--;
|
||||
|
|
Loading…
Reference in a new issue