Skip to content

Commit 11078d6

Browse files
committed
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()
2 parents c09988a + 3696a7c commit 11078d6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

builtin/config.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
568568
}
569569
}
570570
else if (actions == ACTION_EDIT) {
571-
const char *config_file = given_config_source.file ?
572-
given_config_source.file : git_path("config");
571+
char *config_file;
572+
573573
check_argc(argc, 0, 0);
574574
if (!given_config_source.file && nongit)
575575
die("not in a git directory");
@@ -578,6 +578,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
578578
if (given_config_source.blob)
579579
die("editing blobs is not supported");
580580
git_config(git_default_config, NULL);
581+
config_file = xstrdup(given_config_source.file ?
582+
given_config_source.file : git_path("config"));
581583
if (use_global_config) {
582584
int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
583585
if (fd) {
@@ -590,6 +592,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
590592
die_errno(_("cannot create configuration file %s"), config_file);
591593
}
592594
launch_editor(config_file, NULL, NULL);
595+
free(config_file);
593596
}
594597
else if (actions == ACTION_SET) {
595598
int ret;

0 commit comments

Comments
 (0)