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

Re: [PATCH] Support working directory located at root

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 8, 2010, 17:43 UTC
Message-ID
<7v8wb3pqqw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1265640810-6361-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 6 quoted lines
> Git should work regardless where the working directory is located,
> even at root. This patch fixes two places where it assumes working
> directory always have parent directory.
>
> In setup_git_directory_gently(), when Git goes up to root and finds
> .git there, it happily sets worktree to "".

If you mean "instead set it to "/" and things will work much better." I agree with the reasoning (not suggesting to reword---just trying to make sure I understood what you meant).

> In prefix_path(), loosen the outside repo check a little bit. Usually
> when a path XXX is inside worktree /foo, it must be either "/foo", or
> "/foo/...". When worktree is simply "/", we can safely ignore the
> check: we have a slash at the beginning already.

The logic for the "are we inside?" check above sounds correct. When work_tree is at root, have "/" in it, and len inside the "if orig is absolute" block is 1, so memmove() strips out the leading '/' and makes the result relative to the root level. Am I reading the code right?

> Not related to worktree, but also set gitdir correctly if a bare repo
> is placed (insanely?) at root.
Yuck, but looks correct.
Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 2 of 5 in “Support working directory located at root”
  1. Support working directory located at rootNguyễn Thái Ngọc Duy, Feb 8, 2010
  2. Junio C HamanoFeb 8, 2010
  3. Nguyen Thai Ngoc DuyFeb 9, 2010
  4. Nguyen Thai Ngoc DuyFeb 9, 2010
  5. Johannes SixtFeb 8, 2010

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.