Merge branch 'ma/clear-repository-format'
authorJunio C Hamano <gitster@pobox.com>
Wed, 20 Mar 2019 06:16:07 +0000 (15:16 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Mar 2019 06:16:07 +0000 (15:16 +0900)
The setup code has been cleaned up to avoid leaks around the
repository_format structure.

* ma/clear-repository-format:
setup: fix memory leaks with `struct repository_format`
setup: free old value before setting `work_tree`

1  2 
builtin/init-db.c
cache.h
repository.c
setup.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc repository.c
Simple merge
diff --cc setup.c
index ca9e8a949ed869183f16c57520f19fb361100a02,ab6e8fd4c38f73be2c9dc9d9d0b39f8475db6524..d0c958c3b2a4a7d4b53970b0e623ed8f6e6a4be4
+++ b/setup.c
@@@ -1044,8 -1068,8 +1058,8 @@@ const char *setup_git_directory_gently(
  {
        static struct strbuf cwd = STRBUF_INIT;
        struct strbuf dir = STRBUF_INIT, gitdir = STRBUF_INIT;
 -      const char *prefix;
 +      const char *prefix = NULL;
-       struct repository_format repo_fmt;
+       struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
  
        /*
         * We may have read an incomplete configuration before