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
Junio C Hamano <gitster@pobox.com>
Date
Jan 18, 2009, 21:27 UTC
Message-ID
<7vhc3wuwxb.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7vr63386rc.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> I think (1) the solution (almost) makes sense, (2) the patch needs to be
> explained a lot better as you mentioned in your two messages, and (3) if
> it does not affect any other case than when you are in a subdirectory of
> the .git/ directory, then you are doing something funny anyway and
> performance issue Dscho mentions, if any, is not a concern.
>
> My "(almost)" in (1) above is because the patch uses this new behaviour
> even when you are inside the .git/ directory itself (or at the root of a
> bare repository), which is a very common case that we do not have to nor
> want to change the behaviour.  It also invalidates the precondition of (3)
> above.
And this is a trivial follow-up on top of Szeder's patch.
 setup.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git c/setup.c w/setup.c
index 4049298..dd7c039 100644
--- c/setup.c
+++ w/setup.c
@@ -456,8 +456,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			inside_git_dir = 1;
 			if (!work_tree_env)
 				inside_work_tree = 0;
-			cwd[offset] = '\0';
-			setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+			if (offset != len) {
+				cwd[offset] = '\0';
+				setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+			} else
+				setenv(GIT_DIR_ENVIRONMENT, ".", 1);
 			check_repository_format_gently(nongit_ok);
 			return NULL;
 		}
Previous: Johannes SchindelinNext: SZEDER Gábor
Message 8 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.