Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mixed use of real_paths and symlink paths#822

Closed
jiangxin wants to merge 3 commits into
git-lfs:masterfrom
jiangxin:jx/real-path
Closed

Mixed use of real_paths and symlink paths#822
jiangxin wants to merge 3 commits into
git-lfs:masterfrom
jiangxin:jx/real-path

Conversation

@jiangxin

@jiangxin jiangxin commented Nov 9, 2015

Copy link
Copy Markdown
Contributor

Some paths are real paths (all symlinks are resolved) like LocalWorkingDir and git.RootDir(),
which are from the command git rev-parse --show-toplevel. But others (like LocalGitDir and
may others from os.Getwd() are not. This is why when git lfs trace foo on a symlink worktree,
will stop by:

foo is outside repository

I found there is a similar PR #818 , maybe can be merged together. @sinbad

If worktree is a symlink, when track files using `git lfs track ...`,
will stop with the following error message:

    <Filename> is outside repository

This is because when worktree is a symlink, lfs.LocalWorkingDir points
to the real path (all symlinks are resolved), but the symlinks of the
files to be tracked are not resolved yet, so git-lfs makes a mistake.

Signed-off-by: Jiang Xin <[email protected]>
git.RootDir() is from command `git rev-parse --show-toplevel`, which
returns real_path (symlinks are resolved), but git.GitDir() is not.
So if git worktree is on a symlink directory, LocalWorkingDir and
LocalGitDir will be quite different.

Resolve symlinks on git.GitDir() to make it a real_path as git.RootDir().

Signed-off-by: Jiang Xin <[email protected]>
Replace `os.Getwd()` with a wrapper `lfs.Getwd()`, because it's not
safe mixing the symlink paths (from os.Getwd()) with the real paths.

Signed-off-by: Jiang Xin <[email protected]>
@technoweenie

Copy link
Copy Markdown
Contributor

Thanks for the patch! Unfortunately, I went with #818 instead. It has a shell test, and only changes what's necessary to fix that "foo is outside repository" error. We don't need to eval other symlink paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants