# \[PATCH v7 18/31\] setup.c: detect $GIT\_COMMON\_DIR check\_repository\_format\_gently()

- From: Nguyễn Thái Ngọc Duy \<hidden\>
- Date: 2016-06-15 23:01:54 
- List: git
- Page: https://ratatoskr.run/git/2016/06/7636759
- Thread: https://ratatoskr.run/git/2016/06/7636417/t.md

```text
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 setup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index a17389f..79f79f2 100644
--- a/setup.c
+++ b/setup.c
@@ -346,6 +346,10 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 	const char *repo_config;
 	int ret = 0;
 
+	get_common_dir(&sb, gitdir);
+	strbuf_addstr(&sb, "/config");
+	repo_config = sb.buf;
+
 	/*
 	 * git_config() can't be used here because it calls git_pathdup()
 	 * to get $GIT_CONFIG/config. That call will make setup_git_env()
@@ -355,8 +359,6 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 	 * Use a gentler version of git_config() to check if this repo
 	 * is a good one.
 	 */
-	strbuf_addf(&sb, "%s/config", gitdir);
-	repo_config = sb.buf;
 	git_config_early(check_repository_format_version, NULL, repo_config);
 	if (GIT_REPO_VERSION < repository_format_version) {
 		if (!nongit_ok)
-- 
1.9.1.346.ga2b5940
```
