4ff03089e0
In commit d2221dcecacc6a2ad38ffd2e429fca18805cb4ea of PR #2851 the "git lfs prune" command was changed to respect the "lfs.fetchexclude" configuration option such that objects would always be pruned if they were referenced by files whose paths matched one of the patterns in the configuration option (unless they were referenced by an unpushed commit). However, this filter is applied using the GitScanner.ScanRef() method, which indirectly utilizes the internal scanRefsToChan() function, and that function only visits unique OIDs a single time each, even if they are referenced by multiple tree entries (i.e., if there are multiple files with the same content). This means that if an LFS object appears in both a file that matches a pattern from "lfs.fetchexclude" and in a file that does not match, the object may be pruned if the file path seen during the scan is the matching one regardless of whether the non-matching file would otherwise have its object retained. To resolve this we change the pruneTaskGetRetainedAtRef() function to use the GitScanner.ScanTree() method instead of ScanRef(), because ScanTree() visits all file paths in each commit. We need to pass our callback to the ScanTree() method so that we can save all non-matching files' OIDs into our list of OIDs to be retained; therefore we need to add a callback argument to ScanTree() in the same manner as is done for ScanRef() and various other GitScanner methods. We also introduce additional checks in our "prune all excluded paths" test to ensure that we always retain objects when they appear in a commit to be retained and at least one of the files referencing that object ID does not match the "lfs.fetchexclude" filter. |
||
---|---|---|
.. | ||
attribute.go | ||
config_test.go | ||
config.go | ||
diff_index_scanner.go | ||
extension.go | ||
gitfilter_clean.go | ||
gitfilter_smudge.go | ||
gitfilter.go | ||
gitscanner_catfilebatch.go | ||
gitscanner_catfilebatchcheck.go | ||
gitscanner_catfilebatchcheckscanner_test.go | ||
gitscanner_index.go | ||
gitscanner_log.go | ||
gitscanner_pointerscanner_test.go | ||
gitscanner_refs.go | ||
gitscanner_remotes.go | ||
gitscanner_tree.go | ||
gitscanner.go | ||
hook.go | ||
lfs_test.go | ||
lfs.go | ||
pointer_test.go | ||
pointer.go | ||
scanner_git_test.go | ||
scanner_test.go | ||
scanner.go | ||
util_generic.go | ||
util_test.go | ||
util.go |