Don't download on smudge if file is filtered by include/exclude config
This commit is contained in:
parent
6f847ea527
commit
bf8bade4cf
@ -57,7 +57,9 @@ func smudgeCommand(cmd *cobra.Command, args []string) {
|
||||
Error(err.Error())
|
||||
}
|
||||
|
||||
err = ptr.Smudge(os.Stdout, filename, true, cb)
|
||||
cfg := lfs.Config
|
||||
download := lfs.FilenamePassesIncludeExcludeFilter(filename, cfg.FetchIncludePaths(), cfg.FetchExcludePaths())
|
||||
err = ptr.Smudge(os.Stdout, filename, download, cb)
|
||||
if file != nil {
|
||||
file.Close()
|
||||
}
|
||||
|
@ -46,3 +46,33 @@ begin_test "smudge with invalid pointer"
|
||||
[ "wat" = "$(echo "wat" | git lfs smudge)" ]
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "smudge include/exclude"
|
||||
(
|
||||
set -e
|
||||
|
||||
reponame="smudge_includeexclude"
|
||||
setup_remote_repo "$reponame"
|
||||
clone_repo "$reponame" repoincludeexclude
|
||||
|
||||
git lfs track "*.dat"
|
||||
echo "smudge a" > a.dat
|
||||
git add .gitattributes a.dat
|
||||
git commit -m "add a.dat"
|
||||
|
||||
# smudge works even though it hasn't been pushed, by reading from .git/lfs/objects
|
||||
output="$(pointer fcf5015df7a9089a7aa7fe74139d4b8f7d62e52d5a34f9a87aeffc8e8c668254 9 | git lfs smudge)"
|
||||
[ "smudge a" = "$output" ]
|
||||
|
||||
git push origin master
|
||||
|
||||
# this WOULD download except we're going to prevent it with include/exclude
|
||||
rm -rf .git/lfs/objects
|
||||
git config "lfs.fetchexclude" "a*"
|
||||
|
||||
output="$(pointer fcf5015df7a9089a7aa7fe74139d4b8f7d62e52d5a34f9a87aeffc8e8c668254 9 | git lfs smudge a.dat)"
|
||||
# because download was not allowed, contents will be a pointer ie unchanged
|
||||
[ "$(pointer fcf5015df7a9089a7aa7fe74139d4b8f7d62e52d5a34f9a87aeffc8e8c668254 9)" = "$output" ]
|
||||
)
|
||||
end_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user