diff options
author | Joey Hess <joeyh@joeyh.name> | 2023-08-14 12:06:32 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2023-08-14 12:12:52 -0400 |
commit | edf83982be214f3c839fab9b659f645de53a9100 (patch) | |
tree | bef06cb750379c6d7942fc13b13fcb328201354c /Git/Filename.hs | |
parent | f0cd3a2a3758ddcd2f0900c16bdc1fb80bbd6e92 (diff) | |
download | git-repair-edf83982be214f3c839fab9b659f645de53a9100.tar.gz |
merge from git-annex
Support building with unix-compat 0.7
Diffstat (limited to 'Git/Filename.hs')
-rw-r--r-- | Git/Filename.hs | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/Git/Filename.hs b/Git/Filename.hs deleted file mode 100644 index 2fa4c59..0000000 --- a/Git/Filename.hs +++ /dev/null @@ -1,49 +0,0 @@ -{- Some git commands output encoded filenames, in a rather annoyingly complex - - C-style encoding. - - - - Copyright 2010, 2011 Joey Hess <id@joeyh.name> - - - - Licensed under the GNU AGPL version 3 or higher. - -} - -module Git.Filename where - -import Common -import Utility.Format (decode_c, encode_c) -import Utility.QuickCheck - -import Data.Char -import Data.Word -import qualified Data.ByteString as S - --- encoded filenames will be inside double quotes -decode :: S.ByteString -> RawFilePath -decode b = case S.uncons b of - Nothing -> b - Just (h, t) - | h /= q -> b - | otherwise -> case S.unsnoc t of - Nothing -> b - Just (i, l) - | l /= q -> b - | otherwise -> - encodeBS $ decode_c $ decodeBS i - where - q :: Word8 - q = fromIntegral (ord '"') - -{- Should not need to use this, except for testing decode. -} -encode :: RawFilePath -> S.ByteString -encode s = encodeBS $ "\"" ++ encode_c (decodeBS s) ++ "\"" - --- Encoding and then decoding roundtrips only when the string does not --- contain high unicode, because eg, both "\12345" and "\227\128\185" --- are encoded to "\343\200\271". --- --- That is not a real-world problem, and using TestableFilePath --- limits what's tested to ascii, so avoids running into it. -prop_encode_decode_roundtrip :: TestableFilePath -> Bool -prop_encode_decode_roundtrip ts = - s == fromRawFilePath (decode (encode (toRawFilePath s))) - where - s = fromTestableFilePath ts |