Fix "outside repository" error when "git lfs track" in a symlinked dir
This commit is contained in:
parent
b0318b2535
commit
8af895cfb7
@ -62,9 +62,14 @@ ArgsLoop:
|
|||||||
absT, relT := absRelPath(t, wd)
|
absT, relT := absRelPath(t, wd)
|
||||||
|
|
||||||
if !filepath.HasPrefix(absT, lfs.LocalWorkingDir) {
|
if !filepath.HasPrefix(absT, lfs.LocalWorkingDir) {
|
||||||
|
// check symlinks; LocalWorkingDir has symlinks resolved by rev-parse
|
||||||
|
// have to resolve dir without track pattern
|
||||||
|
actualDirT, err := filepath.EvalSymlinks(filepath.Dir(absT))
|
||||||
|
if err != nil || !filepath.HasPrefix(actualDirT, lfs.LocalWorkingDir) {
|
||||||
Print("%s is outside repository", t)
|
Print("%s is outside repository", t)
|
||||||
os.Exit(128)
|
os.Exit(128)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, k := range knownPaths {
|
for _, k := range knownPaths {
|
||||||
absK, _ := absRelPath(k.Path, filepath.Join(wd, filepath.Dir(k.Source)))
|
absK, _ := absRelPath(k.Path, filepath.Join(wd, filepath.Dir(k.Source)))
|
||||||
|
@ -215,3 +215,20 @@ begin_test "track in gitDir"
|
|||||||
exit 1
|
exit 1
|
||||||
)
|
)
|
||||||
end_test
|
end_test
|
||||||
|
|
||||||
|
begin_test "track in symlinked dir"
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
|
||||||
|
git init track-symlinkdst
|
||||||
|
ln -s track-symlinkdst track-symlinksrc
|
||||||
|
cd track-symlinksrc
|
||||||
|
|
||||||
|
git lfs track "*.png"
|
||||||
|
grep "^*.png" .gitattributes || {
|
||||||
|
echo ".gitattributes doesn't contain the expected relative path *.png:"
|
||||||
|
cat .gitattributes
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end_test
|
||||||
|
Loading…
Reference in New Issue
Block a user