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

Re: Difficulty adding a symbolic link, part 3

From
Dale R. Worley <worley@alum.mit.edu>
Date
Aug 1, 2013, 15:00 UTC
Message-ID
<201308011500.r71F03HJ008579@freeze.ariadne.com>
In-Reply-To
<CACsJy8DZ11zFEgL_vZ-kG2tuwodU=vBJZqZxUPWtYh9u8o-_Tg@mail.gmail.com>
> From: Duy Nguyen <pclouds@gmail.com>
Show 18 quoted lines
> > Can someone give me advice on what this code *should* do?
> 
> It does as the function name says: given cwd, a prefix (i.e. a
> relative path with no ".." components) and a path relative to
> cwd+prefix, convert 'path' to something relative to cwd. In the
> simplest case, prepending the prefix to 'path' is enough. cwd is also
> get_git_work_tree().
> 
> I agree with you that this code should not resolve anything in the
> components after 'cwd', after rebasing the path to 'cwd' (not just the
> final component). Not sure how to do it correctly though because we do
> need to resolve symlinks before cwd. Maybe a new variant of real_path
> that stops at 'cwd'?
> 
> We may also have problems with resolve symlinks before cwd when 'path'
> is relative, as normalize_path_copy() does not resolve symlinks. We
> just found out emacs has this bug [1] but did not realize we also have
> one :-P.

Thanks for the detailed information. It seems to me that the minimum needed change is that the handling of relative and absolute paths should be made consistent.

> [1] http://thread.gmane.org/gmane.comp.version-control.git/231268

That problem isn't so much a matter of not resolving symlinks but rather the question of what ".." means. In the case shown in that message, the current directory *is* {topdir}/z/b, but it was entered with "cd {topdir}/b" -- and the shell records the latter as the value of $PWD. (Actually, the bash shell can handle symbolic-linked directories *either* way, depending on whether it is given the "-P" option.)

When Emacs is given the file name "../a/file", does the ".." mean to go up one directory *textually* in the pathspec based on $PWD

"{topdir}/b/../a/file" -> "{topdir}/a/file" (which does not exist)

or according to the directory linkage on the disk (where the ".." entry in the current directory goes to the directory named {topdir}/z, which does contain a file a/file. It looks like Emacs uses the first method.

The decision of which implementation to use depends on the semantics you *want*. As I noted, bash allows the user to choose *either* interpretation, which shows that both semantics are considered valid (by some people).

Dale
Previous: Dale R. WorleyNext: Duy Nguyen
Message 4 of 5 in “Difficulty adding a symbolic link, part 3”
  1. Dale R. WorleyJul 31, 2013
  2. Duy NguyenAug 1, 2013
  3. Dale R. WorleyAug 1, 2013
  4. Dale R. WorleyAug 1, 2013
  5. Duy NguyenAug 2, 2013

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.