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

Re: [PATCH] setup: return correct prefix if worktree is '/'

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 25, 2011, 14:17 UTC
Message-ID
<4D8CA3EF.3010403@drmicha.warpmail.net>
In-Reply-To
<1301060989-7246-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy venit, vidit, dixit 25.03.2011 14:49:
Show 12 quoted lines
> The same old problem reappears after setup code is reworked. We tend
> to assume there is at least one path component in a path and forget
> that path can be simply '/'.
> 
> Reported-by: Matthijs Kooijman <matthijs@stdin.nl>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  cache.h |    2 ++
>  path.c  |   35 +++++++++++++++++++++++++++++++++++
>  setup.c |    5 ++---
>  3 files changed, 39 insertions(+), 3 deletions(-)
> 
Wait wait, the bug bisects to

490544b (get_cwd_relative(): do not misinterpret suffix as subdirectory, 2010-05-22)

for me, using

git bisect run sh -c "make || exit 125; cd /etc; GIT_DIR=/tmp/a/.git ~/src/git/git-add fstab || exit 1"

and a repo in /tmp/a/.git with core.worktree set to "/".

The issue is that in get_relative_cwd() of dir.c, "dir" (and maybe ("cwd") may or may not end in "/", so even with dir="/etc/" and cwd="/etc" we would not recognize we are within the repo. Patch for that is coming.

Note that by doing something like the above, we can test / without being root as long as we have files there which we can rely on being readable, or can rely on /tmp being there.

Michael
Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 4 of 7 in “git-add says 'pathspec did not match any files' for git repository in /”
  1. Matthijs KooijmanMar 25, 2011
  2. Nguyen Thai Ngoc DuyMar 25, 2011
  3. setup: return correct prefix if worktree is '/'Nguyễn Thái Ngọc Duy, Mar 25, 2011
  4. Michael J GruberMar 25, 2011
  5. Nguyen Thai Ngoc DuyMar 25, 2011
  6. dir.c: do not trip over difference in "/"Michael J Gruber, Mar 25, 2011
  7. Nguyen Thai Ngoc DuyMar 26, 2011

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.