Add a --user option to git-config
PATCH 1/1 Add a --user option to git-config
At present, the --global option is something of a misnomer, so we introduce the --user option as a synonym, with the intention of removing the old option in the future.
---
I have recently had the need to create a ~/.gitconfig file for the first time and I was reminded of this patch. Maybe it's just me who thinks that --global is odd ... ;-) Particularly since the system config file was added.
Actually my config editor of choice is vim, so this is not a high priority for me.
[This is against 1.5.2, but will hopefully not be too difficult to forward to current git]
ATB,
Ramsay Jones
Documentation/git-config.txt | 30 +++++++++++++++--------------- Documentation/git-repo-config.txt | 2 +- Documentation/tutorial.txt | 4 ++-- Documentation/user-manual.txt | 2 +- builtin-config.c | 5 +++-- contrib/completion/git-completion.bash | 2 +- ident.c | 2 +- 7 files changed, 24 insertions(+), 23 deletions(-)
Documentation/git-config.txt +15 -15
@@ -3,22 +3,22 @@ git-config(1) NAME ---- -git-config - Get and set repository or global options +git-config - Get and set repository, user or system-wide options SYNOPSIS -------- [verse] -'git-config' [--system | --global] [type] name [value [value_regex]] -'git-config' [--system | --global] [type] --add name value -'git-config' [--system | --global] [type] --replace-all name [value [value_regex]] -'git-config' [--system | --global] [type] --get name [value_regex] -'git-config' [--system | --global] [type] --get-all name [value_regex] -'git-config' [--system | --global] [type] --unset name [value_regex] -'git-config' [--system | --global] [type] --unset-all name [value_regex] -'git-config' [--system | --global] [type] --rename-section old_name new_name -'git-config' [--system | --global] [type] --remove-section name -'git-config' [--system | --global] -l | --list +'git-config' [--system | --user] [type] name [value [value_regex]] +'git-config' [--system | --user] [type] --add name value +'git-config' [--system | --user] [type] --replace-all name [value [value_regex]] +'git-config' [--system | --user] [type] --get name [value_regex] +'git-config' [--system | --user] [type] --get-all name [value_regex] +'git-config' [--system | --user] [type] --unset name [value_regex] +'git-config' [--system | --user] [type] --unset-all name [value_regex] +'git-config' [--system | --user] [type] --rename-section old_name new_name +'git-config' [--system | --user] [type] --remove-section name +'git-config' [--system | --user] -l | --list DESCRIPTION -----------
@@ -47,7 +47,7 @@ This command will fail if: . the section or key is invalid, . you try to unset an option which does not exist, . you try to unset/set an option for which multiple lines match, or -. you use --global option without $HOME being properly set. +. you use --user option without $HOME being properly set. OPTIONS
@@ -73,8 +73,8 @@ OPTIONS --get-regexp:: Like --get-all, but interprets the name as a regular expression. ---global:: - Use global ~/.gitconfig file rather than the repository .git/config. +--user:: + Use per user ~/.gitconfig file rather than the repository .git/config. --system:: Use system-wide $(prefix)/etc/gitconfig rather than the repository
@@ -110,7 +110,7 @@ ENVIRONMENT GIT_CONFIG:: Take the configuration from the given file instead of .git/config. - Using the "--global" option forces this to ~/.gitconfig. + Using the "--user" option forces this to ~/.gitconfig. GIT_CONFIG_LOCAL:: Currently the same as $GIT_CONFIG; when Git will support global
Documentation/git-repo-config.txt +1 -1
@@ -3,7 +3,7 @@ git-repo-config(1) NAME ---- -git-repo-config - Get and set repository or global options +git-repo-config - Get and set repository, user or system-wide options SYNOPSIS
Documentation/tutorial.txt +2 -2
@@ -20,8 +20,8 @@ public email address before doing any operation. The easiest way to do so is: ------------------------------------------------ -$ git config --global user.name "Your Name Comes Here" -$ git config --global user.email [email protected] +$ git config --user user.name "Your Name Comes Here" +$ git config --user user.email [email protected] ------------------------------------------------
Documentation/user-manual.txt +1 -1
@@ -1147,7 +1147,7 @@ The file specified by the `core.excludesfile` config directive::: more information on configuration options). This config directive can be set in the per-repo `.git/config` file, in which case the exclude patterns will apply to that repo only. Alternatively, you - can set the directive in the global `~/.gitconfig` file to apply + can set the directive in the per-user `~/.gitconfig` file to apply the exclude pattern to all your git repos. As with the above `.git/info/exclude` (and, indeed, with git config directives in general), this directive does not follow push/pull/clone, but remain
builtin-config.c +3 -2
@@ -2,7 +2,7 @@#include "cache.h" static const char git_config_set_usage[] = -"git-config [ --global | --system ] [ --bool | --int ] [--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" ; +"git-config [ --user | --system ] [ --bool | --int ] [--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" ;static char *key;static regex_t *key_regexp;
@@ -143,7 +143,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) type =T_BOOL ; else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) return git_config(show_all_config); - else if (!strcmp(argv[1], "--global")) { + else if (!strcmp(argv[1], "--user") || + !strcmp(argv[1], "--global")) { char *home = getenv("HOME"); if (home) { char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
contrib/completion/git-completion.bash +1 -1
@@ -745,7 +745,7 @@ _git_config () case "$cur" in --*) __gitcomp " - --global --list --replace-all + --user --list --replace-all --get --get-all --get-regexp --add --unset --unset-all "
ident.c +1 -1
@@ -182,7 +182,7 @@ static const char *env_hint =" git config user.name \"Your Name\"\n" "\n" "To set the identity in this repository.\n" -"Add --global to set your account\'s default\n" +"Add --user to set your account\'s default\n" "\n" ; const char *fmt_ident(const char *name, const char *email,
Signature · 1 line
1.5.2
Hi,
Quoted 4 lines · Ramsay Jones
At present, the --global option is something of a misnomer, so we introduce the --user option as a synonym, with the intention of removing the old option in the future.
Ack for the intention, except for "removing the old option in the future". We do not need to advertise it, but breaking existing functionality, which might be used by scripts and aliases is bad.
Ciao,
Dscho
Quoted 10 lines · Johannes Schindelin
Quoted 3 lines · Ramsay Jones
At present, the --global option is something of a misnomer, so we introduce the --user option as a synonym, with the intention of removing the old option in the future.
Ack for the intention, except for "removing the old option in the future". We do not need to advertise it, but breaking existing functionality, which might be used by scripts and aliases is bad.
Yep, which is why I made it a synonym; git-gui uses the --global option, for example, and I'm confident that other (user) scripts use it too. The "future" I had in mind was something like 1 year down the road, but it could be longer (or forever) if necessary.
Ramsay Jones
Hi,
Quoted 12 lines · Ramsay Jones
Quoted 10 lines · Johannes Schindelin
Quoted 3 lines · Ramsay Jones
At present, the --global option is something of a misnomer, so we introduce the --user option as a synonym, with the intention of removing the old option in the future.
Ack for the intention, except for "removing the old option in the future". We do not need to advertise it, but breaking existing functionality, which might be used by scripts and aliases is bad.
Quoted 4 lines
Yep, which is why I made it a synonym; git-gui uses the --global option, for example, and I'm confident that other (user) scripts use it too. The "future" I had in mind was something like 1 year down the road, but it could be longer (or forever) if necessary.
Please read my reply as "I vote against ever removing the --global option".
Ciao,
Dscho
Quoted 8 lines · Johannes Schindelin
Quoted 4 lines
Yep, which is why I made it a synonym; git-gui uses the --global option, for example, and I'm confident that other (user) scripts use it too. The "future" I had in mind was something like 1 year down the road, but it could be longer (or forever) if necessary.
Please read my reply as "I vote against ever removing the --global option".
OK.
Ramsay Jones
Quoted 8 lines · Johannes Schindelin
Quoted 5 lines
Yep, which is why I made it a synonym; git-gui uses the --global option, for example, and I'm confident that other (user) scripts use it too. The "future" I had in mind was something like 1 year down the road, but it could be longer (or forever) if necessary.
Please read my reply as "I vote against ever removing the --global option".
I would say with --system present, I do not see much point having the new alias --user either. Get used to it. It is global across the repositories you have control over.
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Johannes Schindelin
Quoted 5 lines
Yep, which is why I made it a synonym; git-gui uses the --global option, for example, and I'm confident that other (user) scripts use it too. The "future" I had in mind was something like 1 year down the road, but it could be longer (or forever) if necessary.
Quoted 7 lines
Quoted 2 lines
Please read my reply as "I vote against ever removing the --global option".
I would say with --system present, I do not see much point having the new alias --user either. Get used to it. It is global across the repositories you have control over.
OK
ATB,
Ramsay Jones