threads / patch / 9278

patchAdd a --user option to git-config

Subject: [PATCH] Add a --user option to git-config

## tl;dr

7 messages between Jul 28, 2007 and Aug 2, 2007. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Ramsay Jones· Jul 28, 2007, 16:35 UTC · lore

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.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

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(-)
Show changes to 7 files +24 −22

Documentation/git-config.txt, Documentation/git-repo-config.txt, Documentation/tutorial.txt, Documentation/user-manual.txt, builtin-config.c, contrib/completion/git-completion.bash, ident.c

diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 280ef20..26138c4 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -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
diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index 2deba31..8eec3cd 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -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
diff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt
index f55d408..a401638 100644
--- a/Documentation/tutorial.txt
+++ b/Documentation/tutorial.txt
@@ -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 you@yourdomain.example.com
+$ git config --user user.name "Your Name Comes Here"
+$ git config --user user.email you@yourdomain.example.com
 ------------------------------------------------
 
 
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 52247aa..105e362 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -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
diff --git a/builtin-config.c b/builtin-config.c
index b2515f7..1850d9d 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -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));
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 46356e8..cb5a457 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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
 			"
diff --git a/ident.c b/ident.c
index 69a04b8..21dca3a 100644
--- a/ident.c
+++ b/ident.c
@@ -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,
-- 
1.5.2
Johannes Schindelin· Jul 28, 2007, 20:04 UTC · re: Ramsay Jones · lore

Re: [PATCH] Add a --user option to git-config

Hi,
On Sat, 28 Jul 2007, Ramsay Jones wrote:
> 
> 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

Ramsay Jones· Jul 31, 2007, 21:54 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Add a --user option to git-config

Johannes Schindelin wrote:
Show 10 quoted lines
> On Sat, 28 Jul 2007, Ramsay Jones wrote:
> 
>> 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
Johannes Schindelin· Aug 1, 2007, 18:13 UTC · re: Ramsay Jones · lore

Re: [PATCH] Add a --user option to git-config

Hi,
On Tue, 31 Jul 2007, Ramsay Jones wrote:
Show 16 quoted lines
> Johannes Schindelin wrote:
> > On Sat, 28 Jul 2007, Ramsay Jones wrote:
> > 
> >> 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.

Please read my reply as "I vote against ever removing the --global option".

Ciao, Dscho

Junio C Hamano· Aug 1, 2007, 18:31 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Add a --user option to git-config

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 8 quoted 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.

Ramsay Jones· Aug 2, 2007, 19:44 UTC · re: Junio C Hamano · lore

Re: [PATCH] Add a --user option to git-config

Junio C Hamano wrote:
Show 14 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
>>> 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.
> 
OK
ATB,
Ramsay Jones
Ramsay Jones· Aug 2, 2007, 17:20 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Add a --user option to git-config

Johannes Schindelin wrote:
Show 8 quoted 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

← back to recent threads