Skip to content

track: make --filename work with spaces#3785

Merged
bk2204 merged 1 commit intogit-lfs:masterfrom
bk2204:track-filename-spaces
Aug 26, 2019
Merged

track: make --filename work with spaces#3785
bk2204 merged 1 commit intogit-lfs:masterfrom
bk2204:track-filename-spaces

Conversation

@bk2204
Copy link
Member

@bk2204 bk2204 commented Aug 21, 2019

When using "git lfs track --filename" with a filename with spaces, the brackets surrounding the character class for representing spaces were also escaped, leading to the space not being interpreted correctly. Update the escaping function we use to handle all of our escaping needs, performing the escaping in the correct order so that we can handle spaces correctly.

/cc @gdlxn-ibm as reporter

@gdlxn-ibm
Copy link

The fix works for me. Thanks for the quick turn around on getting this issue fixed.

Copy link
Contributor

@PastelMobileSuit PastelMobileSuit left a comment

Choose a reason for hiding this comment

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

Had one minor piece of feedback, but otherwise this looks good! ✨

@@ -91,18 +91,17 @@ ArgsLoop:

// Generate the new / changed attrib line for merging
encodedArg := escapeAttrPattern(pattern)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we've merged this functionality into escapeGlobCharacters and so there's no longer any need for this call. I think we should remove it and, since escapeAttrPattern isn't being used anywhere else, we should remove that as well

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the way the diff has displayed is actually a bit misleading here. We want to use escapeAttrPattern in the case when we're not using --filename, since that intentionally doesn't escape glob characters, so *.png stays *.png in the .gitattributes file. But when we use --filename, we do want to escape glob characters, so we use escapeGlobCharacters. The latter just uses parts of the former because the order matters.

I'm wondering, though, if perhaps this would be easier to read as an if/else, where it would be more obvious that escapeAttrPattern is only used if trackFilenameFlag is off. Let me rewrite it that way and see if that's easier to understand.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah of course! That makes sense. Thanks for switching this over to an if-else, it definitely makes things easier to read/understand

@bk2204 bk2204 force-pushed the track-filename-spaces branch from 747f789 to d418b23 Compare August 23, 2019 13:56
When using "git lfs track --filename" with a filename with spaces, the
brackets surrounding the character class for representing spaces were
also escaped, leading to the space not being interpreted correctly.
Update the escaping function we use to handle all of our escaping needs,
performing the escaping in the correct order so that we can handle
spaces correctly.
@bk2204 bk2204 force-pushed the track-filename-spaces branch from d418b23 to fa0f81c Compare August 23, 2019 14:50
Copy link
Contributor

@PastelMobileSuit PastelMobileSuit left a comment

Choose a reason for hiding this comment

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

@bk2204 bk2204 merged commit 726fb94 into git-lfs:master Aug 26, 2019
@bk2204 bk2204 deleted the track-filename-spaces branch August 26, 2019 18:26
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.

3 participants