Update tests to check prune command excludes lfs.fetchexclude paths
#4964
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Several existing tests ensure that the
git lfs prunecommand always retains Git LFS objects referenced by unpushed commits, stashes, and worktrees.However, none of these tests perform checks of the appropriate behaviour when files matching an
lfs.fetchexcludefilter option are involved. Support for pruning Git LFS objects referenced by files matching thelfs.fetchexcludefilter was added in PR #2851. (Support for retaining objects referenced by stashes was added later, in PR #4209).We therefore expand these tests to check for the expected behaviour, which varies depending on the specific case.
For Git LFS objects referenced only by files in unpushed commits or any type of stash (normal, index, or untracked), we now confirm that even if the files' names match a pattern in
lfs.fetchexclude, we still retain the objects locally whengit lfs pruneis run.For Git LFS objects referenced only by files in a commit at the
HEADof a worktree, we now confirm that if the files' names match a pattern inlfs.fetchexclude, then the objects are pruned locally whengit lfs pruneis run. This matches how similar files' objects are pruned even if they are referenced by a regular working tree'sHEADcommit.It may be advantageous to review this PR commit-by-commit as each commit's description provides additional context and details.
Note that we explicitly use a
gitattributes(5)-compatible form of pattern match (i.e.,/foo/**) for thelfs.fetchexcludeoptions in these changes because otherwise we will see failures as per #4945. When that issue is addressed in a future PR we will revise these tests to use the/foopattern match form in order to demonstrate thatgitignore(5)-style matching is being performed./cc @larsxschneider as author of #2851.