From d2221dcecacc6a2ad38ffd2e429fca18805cb4ea Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Thu, 1 Feb 2018 15:39:51 +0100 Subject: [PATCH 1/2] 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. --- commands/command_prune.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/command_prune.go b/commands/command_prune.go index d48eba18..d9b3bf2d 100644 --- a/commands/command_prune.go +++ b/commands/command_prune.go @@ -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) From aee2e197a6407b8b2f444290afd5d1cf3764180b Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Tue, 13 Feb 2018 18:26:34 +0100 Subject: [PATCH 2/2] prune: format code consistently Use the same code structure in pruneTaskGetPreviousVersionsOfRef() as in pruneTaskGetRetainedAtRef(). --- commands/command_prune.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/command_prune.go b/commands/command_prune.go index d9b3bf2d..06b2993b 100644 --- a/commands/command_prune.go +++ b/commands/command_prune.go @@ -347,10 +347,10 @@ func pruneTaskGetPreviousVersionsOfRef(gitscanner *lfs.GitScanner, ref string, s if err != nil { errorChan <- err return - } else { - retainChan <- p.Oid - tracerx.Printf("RETAIN: %v via ref %v >= %v", p.Oid, ref, since) } + + retainChan <- p.Oid + tracerx.Printf("RETAIN: %v via ref %v >= %v", p.Oid, ref, since) }) if err != nil {