Fix smudge/clean filters to work with filenames that have leading dashes

Fixes issue #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
```
This commit is contained in:
epriestley 2016-03-17 14:25:33 -07:00
parent 157751020b
commit fa2ec2fb70
5 changed files with 26 additions and 26 deletions

@ -21,8 +21,8 @@ var (
filters = &Attribute{
Section: "filter.lfs",
Properties: map[string]string{
"clean": "git-lfs clean %f",
"smudge": "git-lfs smudge %f",
"clean": "git-lfs clean -- %f",
"smudge": "git-lfs smudge -- %f",
"required": "true",
},
}
@ -30,8 +30,8 @@ var (
passFilters = &Attribute{
Section: "filter.lfs",
Properties: map[string]string{
"clean": "git-lfs clean %f",
"smudge": "git-lfs smudge --skip %f",
"clean": "git-lfs clean -- %f",
"smudge": "git-lfs smudge --skip -- %f",
"required": "true",
},
}

@ -2,8 +2,8 @@
. "test/testlib.sh"
envInitConfig='git config filter.lfs.smudge = "git-lfs smudge %f"
git config filter.lfs.clean = "git-lfs clean %f"'
envInitConfig='git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"'
begin_test "env with no remote"
(

@ -41,8 +41,8 @@ begin_test "install with old settings"
[ "git lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
git lfs install --force
[ "git-lfs smudge %f" = "$(git config --global filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config --global filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config --global filter.lfs.clean)" ]
)
end_test
@ -130,16 +130,16 @@ begin_test "install --skip-smudge"
set -e
git lfs install
[ "git-lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge %f" = "$(git config --global filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config --global filter.lfs.smudge)" ]
git lfs install --skip-smudge
[ "git-lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge --skip %f" = "$(git config --global filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge --skip -- %f" = "$(git config --global filter.lfs.smudge)" ]
git lfs install --force
[ "git-lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge %f" = "$(git config --global filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config --global filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config --global filter.lfs.smudge)" ]
)
end_test
@ -156,8 +156,8 @@ begin_test "install --local"
git init
git lfs install --local
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs clean %f" = "$(git config --local filter.lfs.clean)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs clean -- %f" = "$(git config --local filter.lfs.clean)" ]
[ "git lfs clean %f" = "$(git config --global filter.lfs.clean)" ]
)
end_test

@ -39,8 +39,8 @@ begin_test "uninstall inside repository with default pre-push hook"
[ -f .git/hooks/pre-push ]
grep "git-lfs" .git/hooks/pre-push
[ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
git lfs uninstall
@ -68,8 +68,8 @@ begin_test "uninstall inside repository without git lfs pre-push hook"
[ -f .git/hooks/pre-push ]
[ "something something git-lfs" = "$(cat .git/hooks/pre-push)" ]
[ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
git lfs uninstall
@ -92,8 +92,8 @@ begin_test "uninstall hooks inside repository"
[ -f .git/hooks/pre-push ]
grep "git-lfs" .git/hooks/pre-push
[ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
git lfs uninstall hooks
@ -102,7 +102,7 @@ begin_test "uninstall hooks inside repository"
exit 1
}
[ "git-lfs smudge %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean %f" = "$(git config filter.lfs.clean)" ]
[ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
)
end_test

@ -3,8 +3,8 @@
. "test/testlib.sh"
ensure_git_version_isnt $VERSION_LOWER "2.5.0"
envInitConfig='git config filter.lfs.smudge = "git-lfs smudge %f"
git config filter.lfs.clean = "git-lfs clean %f"'
envInitConfig='git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"'
begin_test "git worktree"
(