Add -- before %f in the smudge/clean filter configuration

To support filenames starting with dashes.

To update the config of existing repositories, you can re-run git-annex init.

Perhaps it should check every time for the old config and update it, but
that has several problems:

	- read-only repos
	- unexpected commands like `git annex find` changing git configs
	  might be surprising behavior

Since filenames starting with dashes are not super common and the user can
re-init easily enough if their repo needs fixed, I went for the simplest
fix.
This commit is contained in:
Joey Hess 2019-03-18 14:12:13 -04:00
parent e7f3e2a937
commit 60ca3ce043
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 34 additions and 2 deletions

View file

@ -25,6 +25,10 @@ git-annex (7.20190220) UNRELEASED; urgency=medium
the HOME directory.
* addurl --file: Fix a bug that made youtube-dl be used unneccessarily
when adding an html url that does not contain any media.
* Add -- before %f in the smudge/clean filter configuration,
to support filenames starting with dashes.
(To update the config of existing repositories, you can
re-run git-annex init.)
-- Joey Hess <id@joeyh.name> Wed, 20 Feb 2019 14:20:59 -0400

View file

@ -24,8 +24,8 @@ configureSmudgeFilter = unlessM (fromRepo Git.repoIsLocalBare) $ do
-- Avoid that problem by running git status now.
inRepo $ Git.Command.runQuiet [Param "status", Param "--porcelain"]
setConfig (ConfigKey "filter.annex.smudge") "git-annex smudge %f"
setConfig (ConfigKey "filter.annex.clean") "git-annex smudge --clean %f"
setConfig (ConfigKey "filter.annex.smudge") "git-annex smudge -- %f"
setConfig (ConfigKey "filter.annex.clean") "git-annex smudge --clean -- %f"
lf <- Annex.fromRepo Git.attributesLocal
gf <- Annex.fromRepo Git.attributes
lfs <- readattr lf

View file

@ -28,3 +28,5 @@ I'm playing with git-annex on Android and I see the following error messages for
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Sure :)
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,26 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2019-03-18T18:03:41Z"
content="""
No need to complicate this with Android, this is sufficient to reproduce
the problem:
joey@darkstar:/tmp/a>touch ./-foo
joey@darkstar:/tmp/a>git add ./-foo
Invalid option `-foo'
Usage: git-annex smudge (FILE [--clean] | --update)
error: external filter 'git-annex smudge --clean %f' failed 1
The fix is to edit .git/config to contain:
[filter "annex"]
smudge = git-annex smudge -- %f
clean = git-annex smudge --clean -- %f
The added -- before the filename prevents confusing it with an option.
I've done this for new git-annex repositories, and `git annex init` will
also update existing repos.
"""]]