Mixed use of real_paths and symlink paths#822
Closed
jiangxin wants to merge 3 commits into
Closed
Conversation
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]>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andmay others from os.Getwd() are not. This is why when
git lfs trace fooon a symlink worktree,will stop by:
I found there is a similar PR #818 , maybe can be merged together. @sinbad