diff --git a/commands/command_smudge.go b/commands/command_smudge.go index 8f96df39..61184608 100644 --- a/commands/command_smudge.go +++ b/commands/command_smudge.go @@ -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() } diff --git a/test/test-smudge.sh b/test/test-smudge.sh index 5cdd6a56..ee4a9cd5 100755 --- a/test/test-smudge.sh +++ b/test/test-smudge.sh @@ -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 +