@matheusbsbs / matheus-bagliano / commits / 138dd1e990
Fork 0

Do check_repository_format() early

Repository version check is only performed when setup_git_directory() is called. This makes sure setup_git_directory_gently() does the check too. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Nov 29, 2007 at 19:21 UTC 138dd1e990cef5ac0176426016ad5e1f8e5dff58
1 file changed +10 -3
setup.c
+10 -3
@@ -230,8 +230,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
230 static char buffer[1024 + 1];
231 const char *retval;
232
233 - if (!work_tree_env)
234 - return set_work_tree(gitdirenv);
233 + if (!work_tree_env) {
234 + retval = set_work_tree(gitdirenv);
235 + /* config may override worktree
236 + * see set_work_tree comment */
237 + check_repository_format();
238 + return retval;
239 + }
240 + check_repository_format();
241 retval = get_relative_cwd(buffer, sizeof(buffer) - 1,
242 get_git_work_tree());
243 if (!retval || !*retval)
@@ -271,6 +277,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
277 if (!work_tree_env)
278 inside_work_tree = 0;
279 setenv(GIT_DIR_ENVIRONMENT, ".", 1);
280 + check_repository_format();
281 return NULL;
282 }
283 chdir("..");
@@ -291,6 +298,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
298 if (!work_tree_env)
299 inside_work_tree = 1;
300 git_work_tree_cfg = xstrndup(cwd, offset);
301 + check_repository_format();
302 if (offset == len)
303 return NULL;
304
@@ -351,7 +359,6 @@ int check_repository_format(void)
359 const char *setup_git_directory(void)
360 {
361 const char *retval = setup_git_directory_gently(NULL);
354 - check_repository_format();
362
363 /* If the work tree is not the default one, recompute prefix */
364 if (inside_work_tree < 0) {