git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jan 16, 2009, 16:47 UTC
Message-ID
<4970BA2B.7090807@viscovery.net>
In-Reply-To
<alpine.DEB.1.00.0901161729070.3586@pacific.mpi-cbg.de>
Johannes Schindelin schrieb:
Show 13 quoted lines
> Hi,
> 
> On Fri, 16 Jan 2009, SZEDER Gábor wrote:
> 
>>   I'm not sure about setting an absolut path instead of a relative one 
>>   (hence the RFC), although I think it should not make any difference. 
>>   Of course I could have count the number of chdir("..") calls and then 
>>   construct a "../../..", but that would have been more intrusive than 
>>   this two-liner.
> 
> IIRC the absolute paths were shot down already... for performance reasons.
> 
> So we try very hard to keep relative paths instead of absolute ones.
This is a different matter.

The question is basically: How should git behave if $PWD is inside a bare repository? And if you are inside .git/refs, than for git this looks as if it were a bare repository.

The current behavior is that we chdir() up into .git, but do not set a prefix. Nor do we chdir() back where we started after the discovery.

Gábor's patch needs a better justification which misbehavior it tries to fix, and the spot that it changes:

		if (is_git_directory(".")) {
			inside_git_dir = 1;
			if (!work_tree_env)
				inside_work_tree = 0;
			setenv(GIT_DIR_ENVIRONMENT, ".", 1);
			check_repository_format_gently(nongit_ok);
			return NULL;
		}

needs a comment why it does what it does (and that this if-branch is only about bare repositories).

-- Hannes
Previous: Johannes SchindelinNext: Johannes Sixt
Message 3 of 12 in “Fix gitdir detection when in subdir of gitdir”
  1. Fix gitdir detection when in subdir of gitdirSZEDER Gábor, Jan 16, 2009
  2. Johannes SchindelinJan 16, 2009
  3. Johannes SixtJan 16, 2009
  4. Johannes SixtJan 16, 2009
  5. SZEDER GáborJan 16, 2009
  6. Junio C HamanoJan 16, 2009
  7. Johannes SchindelinJan 16, 2009
  8. Junio C HamanoJan 18, 2009
  9. SZEDER GáborJan 19, 2009
  10. Junio C HamanoJan 19, 2009
  11. Johannes SixtJan 19, 2009
  12. t1500: extend with tests of 'git rev-parse --git-dir'SZEDER Gábor, Jan 19, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.