Provide an option to track to handle paths literally#3756
Merged
bk2204 merged 1 commit intogit-lfs:masterfrom Aug 7, 2019
Merged
Provide an option to track to handle paths literally#3756bk2204 merged 1 commit intogit-lfs:masterfrom
bk2204 merged 1 commit intogit-lfs:masterfrom
Conversation
Normally, the arguments to "git lfs track" are taken as glob patterns. This is generally useful, but sometimes there are filenames that contain special characters. Add a "--filename" option that forces arguments to be taken as literal paths instead of glob patterns to make handling these files easier. In the test helpers, pass -F to grep so that our unusual file names don't trigger undesired pattern matching. This has no effect on other tests, as they all pass a literal filename here.
|
I've found that the The last entry was added by
|
Member
Author
|
Thanks for the information. I've opened #3785 to fix that. |
|
Thanks for the quick response. I'll test with the fix for #3785 and let you know how it goes. |
|
The fix for #3785 works for me. Thanks for the quick turn around on getting this issue fixed. |
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 19, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent commit we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the obvious limitation that if a test uses a filename with a space character in it and tries to match that, there could be confusion; however, none of our existing tests require this at the moment.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 20, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent commit we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the obvious limitation that if a test uses a filename with a space character in it and tries to match that, there could be confusion; however, none of our existing tests require this at the moment.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 22, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent commit we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the obvious limitation that if a test uses a filename with a space character in it and tries to match that, there could be confusion; however, none of our existing tests require this at the moment.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 25, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent PR we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the obvious limitation that if a test uses a filename with a space character in it and tries to match that, there could be confusion; however, none of our existing tests require this at the moment.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 25, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent PR we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the obvious limitation that if a test uses a filename with a space character in it and tries to match that, there could be confusion; however, none of our existing tests require this at the moment.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 25, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent PR we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the obvious limitation that if a test uses a filename with a space character in it and tries to match that, there could be confusion; however, none of our existing tests require this at the moment.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 25, 2022
The assert_pointer() and refute_pointer() test helper functions use grep to match specific lines of output from "git ls-tree". However, while assert_pointer() matches with fixed patterns by using grep's -F option, refute_pointer() does not. This difference was introduced in commit fc421da of PR git-lfs#3756, so we update refute_pointer() here to match. In a subsequent PR we will also need to ensure that the file paths we provide as arguments to these functions (specifically, to assert_pointer()) do not match just any part of the paths output by "git ls-tree", but only at the start of the path. That is, "a.bin" should match "a.bin" but not "foo/a.bin". Because the output from "git ls-tree" is space-separated, we prepend a space to our fixed patterns so we match against the start of the file path. This has the limitation that if a test has a file named "foo a.bin", and calls one of these functions with just the filename "a.bin", it will incorrectly match the filename with a space. However, at present only one of our tests that calls either of these functions, specifically the "track: escaped glob pattern with spaces in .gitattributes" test in t/t-track.sh, has a filename with a space in it, and does not create any additional files which might be confused by that filename.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Normally, the arguments to
git lfs trackare taken as glob patterns. This is generally useful, but sometimes there are filenames that contain special characters. Add a--filenameoption that forces arguments to be taken as literal paths instead of glob patterns to make handling these files easier.In the test helpers, pass -F to grep so that our unusual file names don't trigger undesired pattern matching. This has no effect on other tests, as they all pass a literal filename here.
Fixes #3506.