Re: [RFC PATCH] Fix gitdir detection when in subdir of gitdir
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Jan 19, 2009, 07:17 UTC
- Message-ID
- <497428FD.7050301@viscovery.net>
- In-Reply-To
- <20090119020311.GA8753@neumann>
SZEDER Gábor schrieb:
Show 21 quoted lines
> if (is_git_directory(".")) {
> + char gd_rel_path[PATH_MAX];
> inside_git_dir = 1;
> if (!work_tree_env)
> inside_work_tree = 0;
> - setenv(GIT_DIR_ENVIRONMENT, ".", 1);
> + if (cdup_count) {
> + char *p = gd_rel_path;
> + while (cdup_count-- > 1) {
> + *p++ = '.'; *p++ = '.'; *p++ = '/';
> + }
> + *p++ = '.'; *p++ = '.';
> + *p = '\0';
> + } else {
> + gd_rel_path[0] = '.';
> + gd_rel_path[1] = '\0';
> + }
> + setenv(GIT_DIR_ENVIRONMENT, gd_rel_path, 1);
> check_repository_format_gently(nongit_ok);
> return NULL;
> }This does not make sense because you don't chdir back to where you started, so the relative path would be incorrect.
I have the feeling that it is not worth to support this particular use-case with so many lines of code.
-- Hannes