Skip to content

Commit

Permalink
Merge branch 'mh/config-copy-string-from-git-path'
Browse files Browse the repository at this point in the history
* mh/config-copy-string-from-git-path:
  cmd_config(): make a copy of path obtained from git_path()
  • Loading branch information
Junio C Hamano committed Dec 12, 2014
2 parents c09988a + 3696a7c commit 11078d6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions builtin/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 11078d6

Please sign in to comment.