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

Re: bug: git-stash save and symbolic links

From
Jeff King <peff@peff.net>
Date
Oct 20, 2008, 17:55 UTC
Message-ID
<20081020175517.GA18539@coredump.intra.peff.net>
In-Reply-To
<df1390cc0810200839q5eddad1cp4bc14762724d8848@mail.gmail.com>
On Mon, Oct 20, 2008 at 05:39:31PM +0200, Simon Strandgaard wrote:
Show 6 quoted lines
>      mkdir test &&
>      echo content >test/file2 &&
>      git add test/file2 &&
>      git commit -m two &&
>    cd .. &&
>      ln -s repo/test linked &&

Ah, OK. You have a symlink into a subdirectory of the repository. Git correctly finds the repository's .git directory, but then when we attempt to 'cd' to the top-level of the working tree, we end up outside of the repository. The culprit is actually "git rev-parse --show-cdup". This demonstrates it more simply:

  mkdir repo &&
  (cd repo && git init) &&
  mkdir repo/dir &&
  ln -s repo/dir linked &&
  cd linked && git rev-parse --show-cdup

which prints "../". But that's not right; we actually need to go to "../repo".

I think the right solution in this situation is that we should _not_ be setting is_inside_work_tree in setup_git_directory_gently, so that we chdir to its absolute path. But I don't think we ever actually detect the symlink during this setup, so I'm not sure how best to realize we are _in_ this situation.

-Peff
Previous: Simon Strandgaard
Message 5 of 5 in “bug: git-stash save and symbolic links”
  1. Simon StrandgaardOct 20, 2008
  2. Jeff KingOct 20, 2008
  3. Simon StrandgaardOct 20, 2008
  4. Simon StrandgaardOct 20, 2008
  5. Jeff KingOct 20, 2008

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.