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

Re: [PATCH] git rev-parse: Fix --show-cdup inside symlinked directory

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 15, 2008, 15:19 UTC
Message-ID
<alpine.DEB.1.00.0807151614510.8950@racer>
In-Reply-To
<20080715145920.13529.25603.stgit@localhost>
Hi,
On Tue, 15 Jul 2008, Petr Baudis wrote:
Show 6 quoted lines
> Consider the scenario when someone makes a symlink into a working tree
> subdirectory at an unrelated place, then attempts to work inside the
> symlinked directory. The scenario is a bit unwieldly, but most of
> the Git will handle it fine - except git rev-parse --show-cdup. That
> will output a sequence of ../ which will work wrong inside the symlink
> using shell cd builtin.

Short version: do not use symlinks in the working directory, if you do not want to track the _symlink_.

Long version: there are a lot of problems with that, and --show-cdup is the least of the problems. A checkout, for example, is able to kill the symlink and check out a fresh copy of the subdirectory.

AFAICT this is a concious decision: If you want to track a symlink, track a symlink, but if you want to track a subdirectory, you will have to track a subdirectory, and it cannot be a symlink.

> This patch changes --show-cdup to always show absolute workdir path
> instead. I think this should hopefully cause no compatibility problems;
> the testsuite is passing fine, at least.

See the thread where I proposed a change like this, back with the infamous worktree desaster, and Junio NACKed; or the thread where Linus rightfully insists that git_dir should be relative if possible, for performance reasons.

Hth, Dscho

Previous: Petr BaudisNext: Petr Baudis
Message 3 of 8 in “git-rev-parse --show-cdup returns a relative path instead of absolute (problem with git pull --rebase not finding the git dir)”
  1. Yves OrtonJul 15, 2008
  2. git rev-parse: Fix --show-cdup inside symlinked directoryPetr Baudis, Jul 15, 2008
  3. Johannes SchindelinJul 15, 2008
  4. Petr BaudisJul 15, 2008
  5. Yves OrtonJul 15, 2008
  6. Yves OrtonJul 15, 2008
  7. Rogan DawesJul 15, 2008
  8. Yves OrtonJul 15, 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.