path: always pass in commondir to update_common_dir
authorBrandon Williams <bmwill@google.com>
Thu, 22 Jun 2017 18:43:36 +0000 (11:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 24 Jun 2017 01:24:34 +0000 (18:24 -0700)
Instead of passing in 'NULL' and having 'update_common_dir()' query for
the commondir, have the callers of 'update_common_dir()' be responsible
for providing the commondir.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
diff --git a/path.c b/path.c
index 41c861c9658044ad2c7165c5f8d51985956befd2..2434921d8e69ca668833b6c1ef7d8b290bd690dd 100644 (file)
--- a/path.c
+++ b/path.c
@@ -345,8 +345,6 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len,
 {
        char *base = buf->buf + git_dir_len;
        init_common_trie();
-       if (!common_dir)
-               common_dir = get_git_common_dir();
        if (trie_find(&common_trie, base, check_common, NULL) > 0)
                replace_dir(buf, git_dir_len, common_dir);
 }
@@ -387,7 +385,7 @@ static void adjust_git_path(struct strbuf *buf, int git_dir_len)
        else if (git_hooks_path && dir_prefix(base, "hooks"))
                replace_dir(buf, git_dir_len + 5, git_hooks_path);
        else if (the_repository->different_commondir)
-               update_common_dir(buf, git_dir_len, NULL);
+               update_common_dir(buf, git_dir_len, get_git_common_dir());
 }
 
 static void do_git_path(const struct worktree *wt, struct strbuf *buf,