summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-12-12 22:31:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-12-12 22:31:33 (GMT)
commit11078d66d9081e51d6f48f48c6e05a27902dc7e5 (patch)
treed3c99301a56ad6a3ce579dc2d6c8b1d0607c63c7
parentc09988ad940338eae5e2dbaa492bc4705ec5cb6a (diff)
parent3696a7c2d9a4f3227dd7719b734e9db242aae6af (diff)
downloadgit-11078d66d9081e51d6f48f48c6e05a27902dc7e5.zip
git-11078d66d9081e51d6f48f48c6e05a27902dc7e5.tar.gz
git-11078d66d9081e51d6f48f48c6e05a27902dc7e5.tar.bz2
Merge branch 'mh/config-copy-string-from-git-path'
* mh/config-copy-string-from-git-path: cmd_config(): make a copy of path obtained from git_path()
-rw-r--r--builtin/config.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 8cc2604..606a3c0 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -568,8 +568,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
}
}
else if (actions == ACTION_EDIT) {
- const char *config_file = given_config_source.file ?
- given_config_source.file : git_path("config");
+ char *config_file;
+
check_argc(argc, 0, 0);
if (!given_config_source.file && nongit)
die("not in a git directory");
@@ -578,6 +578,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
if (given_config_source.blob)
die("editing blobs is not supported");
git_config(git_default_config, NULL);
+ config_file = xstrdup(given_config_source.file ?
+ given_config_source.file : git_path("config"));
if (use_global_config) {
int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (fd) {
@@ -590,6 +592,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
die_errno(_("cannot create configuration file %s"), config_file);
}
launch_editor(config_file, NULL, NULL);
+ free(config_file);
}
else if (actions == ACTION_SET) {
int ret;