From 34eb33407d4d7eef6d7ddcd6e51525018ef9edf7 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 2 Nov 2006 10:44:20 -0500 Subject: Add --global option to git-repo-config. Allow user to set variables in global ~/.gitconfig file using command line. Signed-off-by: Sean Estabrooks Signed-off-by: Junio C Hamano --- builtin-repo-config.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'builtin-repo-config.c') diff --git a/builtin-repo-config.c b/builtin-repo-config.c index f60cee1dc5..7b6e5725ae 100644 --- a/builtin-repo-config.c +++ b/builtin-repo-config.c @@ -3,7 +3,7 @@ #include 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++; -- cgit v1.2.1