aboutsummaryrefslogtreecommitdiff
path: root/builtin-repo-config.c
diff options
context:
space:
mode:
authorSean <seanlkml@sympatico.ca>2006-11-02 10:44:20 -0500
committerJunio C Hamano <junkio@cox.net>2006-11-02 18:04:40 -0800
commit34eb33407d4d7eef6d7ddcd6e51525018ef9edf7 (patch)
tree4b238e41fc5dd43077a1941eefeb5f589df9173e /builtin-repo-config.c
parentca8e2d86c44e5cea0def1d01edfb4e6aaf642dee (diff)
downloadgit-34eb33407d4d7eef6d7ddcd6e51525018ef9edf7.tar.gz
git-34eb33407d4d7eef6d7ddcd6e51525018ef9edf7.tar.xz
Add --global option to git-repo-config.
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>
Diffstat (limited to 'builtin-repo-config.c')
-rw-r--r--builtin-repo-config.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index f60cee1dc..7b6e5725a 100644
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
@@ -3,7 +3,7 @@
#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;
@@ -139,7 +139,16 @@ int cmd_repo_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
+ 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++;