2010/7/24 Jonathan Nieder <jrnieder@xxxxxxxxx>: > +static const char *setup_explicit_git_dir(const char *gitdirenv, > + const char *work_tree_env, int *nongit_ok) > +{ > + static char buffer[1024 + 1]; > + const char *retval; > + > + if (PATH_MAX - 40 < strlen(gitdirenv)) > + die("'$%s' too big", GIT_DIR_ENVIRONMENT); > + if (!is_git_directory(gitdirenv)) { > + if (nongit_ok) { > + *nongit_ok = 1; > + return NULL; > + } > + die("Not a git repository: '%s'", gitdirenv); > + } > + if (!work_tree_env) { > + retval = set_work_tree(gitdirenv); > + /* config may override worktree */ > + if (check_repository_format_gently(nongit_ok)) > + return NULL; > + return retval; > + } > + if (check_repository_format_gently(nongit_ok)) > + return NULL; > + retval = get_relative_cwd(buffer, sizeof(buffer) - 1, > + get_git_work_tree()); Note to self, cwd should be passed to setup_explicit_git_dir, then drop get_relative_cwd() in favor of prefixcmp(). One less getcwd call, buffer will not be not needed. And probably easier to understand. -- Duy ��.n��������+%������w��{.n��������n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�