aboutsummaryrefslogtreecommitdiff
path: root/Git/LsFiles.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-30 19:00:04 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-30 19:00:04 -0400
commit0dd421db36e271b912895cd4e162ff08a3341e9d (patch)
tree35bc4d74049f7d1be84c27367a59f88eb4473897 /Git/LsFiles.hs
parenta73263035e25f3f0c1b0befc7cb42e329af0af3d (diff)
workaround git ls-files bug in handling slash-escaped wildcards
There's no good solution for git-annex here; I can't escape or un-escape and avoid breaking in some cases, so I've chosen the combo least likely to result in breakage. Git really needs to fix its behavior here. The only other thing git-annex could do is treat this as a feature, and don't try to escape at all. Ugh.
Diffstat (limited to 'Git/LsFiles.hs')
-rw-r--r--Git/LsFiles.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index 3f001f513..c4870be0e 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -36,12 +36,22 @@ import Data.Char
{- Somewhat unexpectedly, git-ls-files does its own wildcard expansion
- of files passed to it. To avoid that, and only get back exactly the
- - files we asked for, slash-escape punctuation in the filename. -}
+ - files we asked for, slash-escape wildcards in the filename.
+ -
+ - This should also slash-escape [], since character classes are expanded
+ - too. However, git refuses to recurse into directories containing
+ - slash-escaped characters (apparently a bug). Since it's rare
+ - for a user-supplied "[foo]" to match multiple files, and it's not too
+ - uncommon to use [] in directory names, we compromise by not escaping
+ - them.
+ -
+ - Complained to the git developers about this behavior on 30 Mar 2016.
+ -}
mkFile :: FilePath -> CommandParam
mkFile = File . concatMap go
where
go c
- | c `elem` "*?[]" = ['\\', c]
+ | c `elem` "*?" = ['\\', c]
| otherwise = [c]
{- Scans for files that are checked into git at the specified locations. -}