aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/init-db.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-29 12:47:53 -0800
committerJunio C Hamano <gitster@pobox.com>2019-01-29 12:47:54 -0800
commit773e4088819cb17150afd4929f32bccabb8e2acd (patch)
tree16a345c12e869466049d0c6641b783c32ed84c83 /builtin/init-db.c
parentMerge branch 'pw/diff-color-moved-ws-fix' (diff)
parentbuiltin_diff(): read $GIT_DIFF_OPTS closer to use (diff)
downloadgit-773e4088819cb17150afd4929f32bccabb8e2acd.tar.gz
git-773e4088819cb17150afd4929f32bccabb8e2acd.zip
Merge branch 'jk/save-getenv-result'
There were many places the code relied on the string returned from getenv() to be non-volatile, which is not true, that have been corrected. * jk/save-getenv-result: builtin_diff(): read $GIT_DIFF_OPTS closer to use merge-recursive: copy $GITHEAD strings init: make a copy of $GIT_DIR string config: make a copy of $GIT_CONFIG string commit: copy saved getenv() result get_super_prefix(): copy getenv() result
Diffstat (limited to 'builtin/init-db.c')
-rw-r--r--builtin/init-db.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 41faffd28d..93eff7618c 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -542,8 +542,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
* GIT_WORK_TREE makes sense only in conjunction with GIT_DIR
* without --bare. Catch the error early.
*/
- git_dir = getenv(GIT_DIR_ENVIRONMENT);
- work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
+ git_dir = xstrdup_or_null(getenv(GIT_DIR_ENVIRONMENT));
+ work_tree = xstrdup_or_null(getenv(GIT_WORK_TREE_ENVIRONMENT));
if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
die(_("%s (or --work-tree=<directory>) not allowed without "
"specifying %s (or --git-dir=<directory>)"),
@@ -582,6 +582,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
}
UNLEAK(real_git_dir);
+ UNLEAK(git_dir);
+ UNLEAK(work_tree);
flags |= INIT_DB_EXIST_OK;
return init_db(git_dir, real_git_dir, template_dir, flags);