Re: [PATCH 3/9] setup: split off $GIT_DIR-set case from setup_git_directory_gently
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Jul 24, 2010, 12:15 UTC
- Message-ID
- <AANLkTikvG8qUgd0p=moft1+7L+L-knVt0AZP0o=rsEmM@mail.gmail.com>
- In-Reply-To
- <20100724111944.GC16054@burratino>
2010/7/24 Jonathan Nieder <jrnieder@gmail.com>:
Show 26 quoted lines
> +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