Skip to content

Fix smudge/clean on files that begin with a dash#1083

Merged
technoweenie merged 2 commits intogit-lfs:masterfrom
epriestley:unusual-filenames2
Mar 18, 2016
Merged

Fix smudge/clean on files that begin with a dash#1083
technoweenie merged 2 commits intogit-lfs:masterfrom
epriestley:unusual-filenames2

Conversation

@epriestley
Copy link
Copy Markdown

Fixes #1072. Currently, the filters run a command like this when a tracked file begins with a dash:

$ git-lfs clean -filename

The filename is then misinterpreted as short arguments.

This installs git-lfs clean -- %f instead of git-lfs clean %f, and a similar smudge filter.

A limitation of this patch is that existing installs don't automatically upgrade to the new filters until they run git lfs install --force. It looks like this is consistent with the git lfs clean vs git-lfs clean precedent, but maybe encountering this behavior is realistic enough to justify trying to build some sort of auto-upgrade feature which promotes known older variants of the filter (it looks like the pre-push hook has such a list already).

In any case, this should fix new installs, and allow existing installs to use git lfs install --force to manually apply the fix.

epriestley added 2 commits March 17, 2016 14:45
See issue git-lfs#1072 for details.

```
git-lfs/ $ ./test/test-unusual-filenames.sh
...
test: push unusually named files ...                               FAILED
...
    [master (root-commit) 0bec008] add files
     2 files changed, 1 insertion(+)
     create mode 100644 -dash.dat
     create mode 100644 .gitattributes
...
    Error: unknown shorthand flag: 'd' in -dash.dat
```
Fixes issue git-lfs#1072. Currently, `git-lfs` installs filters which misinterpret
filenames with leading dashes as command line flags. Separate paths with a
double dash (`--`) when installing filters so these files are handled
properly.

The failing test now passes:

```
$ ./test/test-unusual-filenames.sh
...
test: push unusually named files ...                               OK
test: pull unusually named files ...                               OK
```
@epriestley
Copy link
Copy Markdown
Author

I'm not sure how to reproduce that test failure locally, it passes in my environment:

$ ./test/test-smudge.sh 
compile git-lfs for ./test/test-smudge.sh
commands/mancontent_gen.go
Using go1.6
Git LFS: /Users/epriestley/dev/git-lfs/bin/git-lfs
git-lfs/1.1.1 (GitHub; darwin amd64; go 1.6; git fa2ec2f)
git version 2.5.4 (Apple Git-61)
Updated pre-push hook.
Git LFS initialized.

HOME: /Users/epriestley/dev/git-lfs/test/remote/home
TMP: /Users/epriestley/dev/git-lfs/tmp
CREDS: /Users/epriestley/dev/git-lfs/test/remote/creds
lfstest-gitserver:
  LFSTEST_URL=/Users/epriestley/dev/git-lfs/test/remote/url
  LFSTEST_SSL_URL=/Users/epriestley/dev/git-lfs/test/remote/sslurl
  LFSTEST_CERT=/Users/epriestley/dev/git-lfs/test/remote/cert
  LFSTEST_DIR=/Users/epriestley/dev/git-lfs/test/remote
GIT:
filter.lfs.clean git-lfs clean -- %f
filter.lfs.smudge git-lfs smudge -- %f
filter.lfs.required true
credential.helper lfstest
user.name Git LFS Tests
user.email git-lfs@example.com

test: smudge ...                                                   OK
test: smudge --info ...                                            OK
test: smudge with temp file ...                                    OK
test: smudge with invalid pointer ...                              OK
test: smudge include/exclude ...                                   OK
test: smudge with skip ...                                         OK
test: smudge clone with include/exclude ...                        OK

@technoweenie
Copy link
Copy Markdown
Contributor

Hey, thanks so much for stopping by and contributing all these patches 🤘

This is the first time that the clean/smudge filters have changed. I think it'd be good to have git lfs update or git lfs install (which you should be running after every update) automatically fix the filters, so users don't have to run it with --force. As you can tell, we've already run into this with the content of the pre-push hooks.

Also, that test failure is a wonderful intermittent issue, apparently. Don't worry about it in the context of this PR: #1086

technoweenie added a commit that referenced this pull request Mar 18, 2016
Fix smudge/clean on files that begin with a dash
@technoweenie technoweenie merged commit 890f4ea into git-lfs:master Mar 18, 2016
@technoweenie technoweenie mentioned this pull request Mar 18, 2016
17 tasks
@epriestley
Copy link
Copy Markdown
Author

Ah, thanks for the pointer on the test failure. Spooky! 👻

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.

Incorrect behavior when a filename starts with dash

2 participants