Skip to content

Teach gitscanner how to filter in ScanTree()#1745

Merged
technoweenie merged 3 commits intomasterfrom
gitscanner-filter
Dec 7, 2016
Merged

Teach gitscanner how to filter in ScanTree()#1745
technoweenie merged 3 commits intomasterfrom
gitscanner-filter

Conversation

@technoweenie
Copy link
Contributor

This removes the inline filepathfilter checking from the commands, relying on the gitscanner to do it.

Copy link
Contributor

@ttaylorr ttaylorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one comment, otherwise looks good 👍

}

func checkoutFromFetchChan(gitscanner *lfs.GitScanner, filter *filepathfilter.Filter, in chan *lfs.WrappedPointer) {
func checkoutFromFetchChan(in chan *lfs.WrappedPointer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function still needs a *filepathfilter.Filter. Additionally, we should probably put a safety net around this and guard it with an integration test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, a pull operation is split into two steps:

  1. fetch: Call ScanTree() and download unique LFS objects. This uses the filters properly.
  2. checkout: Call ScanTree() again, and ensure all filenames matching the downloaded OIDs have their LFS pointers converted.

There is a subtle bug that my test does not catch:

Let's say I have a repo with the following duplicate LFS objects:

  • file1.bin
  • file1-copy.bin
  • dupe.bin

If I run git lfs pull --include=file*.bin, it should download 1 object, but only checkout file1.bin and file1-copy.bin. I don't think it necessarily hurts anything to convert dupe.bin, but it feels inconsistent.

Also, I think I can rewrite pull() to run the command a single time, download unique LFS objects just once, but checkout duplicate LFS objects with different filenames.

@technoweenie
Copy link
Contributor Author

Added a test that guards the original behavior: bce58fc

I really want to refactor pull(), but there are still more changes coming to the progress meter and transfer queue so it doesn't require a pointer slice upfront.

@technoweenie technoweenie merged commit 7003fd6 into master Dec 7, 2016
@technoweenie technoweenie deleted the gitscanner-filter branch December 7, 2016 02:24
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Jun 6, 2023
In commit d5fd152 of PR git-lfs#1745 the
"git lfs fetch" command, among others, was revised to set the Filter
element of the GitScanner structure, and no longer pass a common
GitScanner created in the main fetchCommand() function to various
other functions such as scanAll() and fetchAll().

As a result, the GitScanner structure created in the fetchCommand()
function was no longer used, but it was not fully removed at the time,
as was done in the "git lfs checkout" command's checkoutCommand()
function, for instance.  Therefore we can simply remove this unused
structure's initialization now in the fetchCommand() function.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Jun 7, 2023
In commit d5fd152 of PR git-lfs#1745 the
"git lfs fetch" command, among others, was revised to set the Filter
element of the GitScanner structure, and no longer pass a common
GitScanner created in the main fetchCommand() function to various
other functions such as scanAll() and fetchAll().

As a result, the GitScanner structure created in the fetchCommand()
function was no longer used, but it was not fully removed at the time,
as was done in the "git lfs checkout" command's checkoutCommand()
function, for instance.  Therefore we can simply remove this unused
structure's initialization now in the fetchCommand() function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants