Merge pull request #2463 from git-lfs/track-symlink-wd

commands/track: resolve symlinks before comparing attr paths
This commit is contained in:
Taylor Blau 2017-07-31 15:54:14 -06:00 committed by GitHub
commit 211e886290
2 changed files with 26 additions and 0 deletions

@ -56,6 +56,7 @@ func trackCommand(cmd *cobra.Command, args []string) {
} }
wd, _ := tools.Getwd() wd, _ := tools.Getwd()
wd = tools.ResolveSymlinks(wd)
relpath, err := filepath.Rel(config.LocalWorkingDir, wd) relpath, err := filepath.Rel(config.LocalWorkingDir, wd)
if err != nil { if err != nil {
Exit("Current directory %q outside of git working directory %q.", wd, config.LocalWorkingDir) Exit("Current directory %q outside of git working directory %q.", wd, config.LocalWorkingDir)

@ -463,3 +463,28 @@ begin_test "track escaped pattern"
assert_attributes_count "\\#" "filter=lfs" 1 assert_attributes_count "\\#" "filter=lfs" 1
) )
end_test end_test
begin_test "track (symlinked repository)"
(
set -e
reponame="tracked-symlinked-repository"
git init "$reponame"
cd "$reponame"
touch a.dat
pushd .. > /dev/null
dir="tracked-symlinked-repository-tmp"
mkdir -p "$dir"
ln -s "../$reponame" "./$dir"
cd "$dir/$reponame"
[ "Tracking \"a.dat\"" = "$(git lfs track "a.dat")" ]
[ "\"a.dat\" already supported" = "$(git lfs track "a.dat")" ]
popd > /dev/null
)
end_test