Subject: Re: [RFC PATCH] Fix gitdir detection when in subdir of gitdir

From: Johannes Sixt <[email-masked]>
Date: Mon, 19 Jan 2009 08:17:17 +0100

SZEDER Gábor schrieb:
>  		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