summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ca8e2d8)
raw | patch | inline | side by side (parent: ca8e2d8)
author | Sean <seanlkml@sympatico.ca> | |
Thu, 2 Nov 2006 15:44:20 +0000 (10:44 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 3 Nov 2006 02:04:40 +0000 (18:04 -0800) |
Allow user to set variables in global ~/.gitconfig file
using command line.
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
using command line.
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-repo-config.txt | patch | blob | history | |
builtin-repo-config.c | patch | blob | history |
index 8a1ab61e943aba92aed6734c949b196850914a3a..8199615dde6630124c155bb4a296603dc8829c83 100644 (file)
NAME
----
-git-repo-config - Get and set options in .git/config
+git-repo-config - Get and set repository or global options.
SYNOPSIS
--------
[verse]
-'git-repo-config' [type] name [value [value_regex]]
-'git-repo-config' [type] --replace-all name [value [value_regex]]
-'git-repo-config' [type] --get name [value_regex]
-'git-repo-config' [type] --get-all name [value_regex]
-'git-repo-config' [type] --unset name [value_regex]
-'git-repo-config' [type] --unset-all name [value_regex]
-'git-repo-config' -l | --list
+'git-repo-config' [--global] [type] name [value [value_regex]]
+'git-repo-config' [--global] [type] --replace-all name [value [value_regex]]
+'git-repo-config' [--global] [type] --get name [value_regex]
+'git-repo-config' [--global] [type] --get-all name [value_regex]
+'git-repo-config' [--global] [type] --unset name [value_regex]
+'git-repo-config' [--global] [type] --unset-all name [value_regex]
+'git-repo-config' [--global] -l | --list
DESCRIPTION
-----------
. Can not write to .git/config,
. no section was provided,
. the section or key is invalid,
-. you try to unset an option which does not exist, or
-. you try to unset/set an option for which multiple lines match.
+. 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.
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.
+
--unset::
- Remove the line matching the key from .git/config.
+ Remove the line matching the key from config file.
--unset-all::
- Remove all matching lines from .git/config.
+ Remove all matching lines from config file.
-l, --list::
- List all variables set in .git/config.
+ List all variables set in config file.
ENVIRONMENT
GIT_CONFIG::
Take the configuration from the given file instead of .git/config.
+ Using the "--global" option forces this to ~/.gitconfig.
GIT_CONFIG_LOCAL::
Currently the same as $GIT_CONFIG; when Git will support global
diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index f60cee1dc54497d8ba00069a56e14b431f6a0852..7b6e5725ae6d33350a9648e57139b646ab49696e 100644 (file)
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
#include <regex.h>
static const char git_config_set_usage[] =
-"git-repo-config [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";
+"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";
static char *key;
static regex_t *key_regexp;
type = T_BOOL;
else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
return git_config(show_all_config);
- else
+ else if (!strcmp(argv[1], "--global")) {
+ char *home = getenv("HOME");
+ if (home) {
+ char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
+ setenv("GIT_CONFIG", user_config, 1);
+ free(user_config);
+ } else {
+ die("$HOME not set");
+ }
+ } else
break;
argc--;
argv++;