prune: always prune excluded paths

People use 'lfs.fetchexclude' to limit the download of Git LFS content.
If a user excludes Git LFS files with 'lfs.fetchexclude' after a full
clone, then Git LFS would not smudge the files in the working directory
but it would keep the LFS content in the LFS storage directory (usually
.git/lfs/objects). Git LFS would keep the LFS content even after a
'git lfs prune' run.

Change that behavior and prune all objects that match the
'lfs.fetchexclude' pattern independent of their age.
This commit is contained in:
Lars Schneider 2018-02-01 15:39:51 +01:00
parent dda06f2361
commit d2221dceca

@ -7,6 +7,7 @@ import (
"sync"
"time"
"github.com/git-lfs/git-lfs/filepathfilter"
"github.com/git-lfs/git-lfs/fs"
"github.com/git-lfs/git-lfs/git"
"github.com/git-lfs/git-lfs/lfs"
@ -86,6 +87,8 @@ func prune(fetchPruneConfig lfs.FetchPruneConfig, verifyRemote, dryRun, verbose
retainChan := make(chan string, 100)
gitscanner := lfs.NewGitScanner(nil)
gitscanner.Filter = filepathfilter.New(nil, cfg.FetchExcludePaths())
go pruneTaskGetRetainedCurrentAndRecentRefs(gitscanner, fetchPruneConfig, retainChan, errorChan, &taskwait)
go pruneTaskGetRetainedUnpushed(gitscanner, fetchPruneConfig, retainChan, errorChan, &taskwait)
go pruneTaskGetRetainedWorktree(gitscanner, retainChan, errorChan, &taskwait)