@matheusbsbs / matheus-bagliano / commits / 1cd8031b2d
Fork 0

setup: clean up setup_bare_git_dir()

work_tree_env argument is removed because this function does not need it. GIT_WORK_TREE is only effective inside setup_explicit_git_dir. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Nov 26, 2010 at 22:32 UTC 1cd8031b2d2e937239918a3a498b1b217a198cc1
1 file changed +9 -10
setup.c
+9 -10
@@ -405,26 +405,25 @@ static const char *setup_discovered_git_dir(const char *work_tree_env,
405 return cwd + offset;
406 }
407
408 -static const char *setup_bare_git_dir(const char *work_tree_env,
409 - int offset, int len, char *cwd, int *nongit_ok)
408 +/* #16.1, #17.1, #20.1, #21.1, #22.1 (see t1510) */
409 +static const char *setup_bare_git_dir(char *cwd, int offset, int len, int *nongit_ok)
410 {
411 int root_len;
412
413 + if (check_repository_format_gently(".", nongit_ok))
414 + return NULL;
415 +
416 inside_git_dir = 1;
414 - if (!work_tree_env)
415 - inside_work_tree = 0;
417 + inside_work_tree = 0;
418 if (offset != len) {
419 if (chdir(cwd))
420 die_errno("Cannot come back to cwd");
421 root_len = offset_1st_component(cwd);
422 cwd[offset > root_len ? offset : root_len] = '\0';
423 set_git_dir(cwd);
422 - check_repository_format_gently(cwd, nongit_ok);
424 }
424 - else {
425 + else
426 set_git_dir(".");
426 - check_repository_format_gently(".", nongit_ok);
427 - }
427 return NULL;
428 }
429
@@ -509,8 +508,8 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
508 offset, len,
509 cwd, nongit_ok);
510 if (is_git_directory("."))
512 - return setup_bare_git_dir(work_tree_env, offset,
513 - len, cwd, nongit_ok);
511 + return setup_bare_git_dir(cwd, offset, len, nongit_ok);
512 +
513 while (--offset > ceil_offset && cwd[offset] != '/');
514 if (offset <= ceil_offset)
515 return setup_nongit(cwd, nongit_ok);