git-annex/Utility
Joey Hess d8fb97806c support all filename encodings with ghc 7.4
Under ghc 7.4, this seems to be able to handle all filename encodings
again. Including filename encodings that do not match the LANG setting.
I think this will not work with earlier versions of ghc, it uses some ghc
internals.

Turns out that ghc 7.4 has a special filesystem encoding that it uses when
reading/writing filenames (as FilePaths). This encoding is documented
to allow  "arbitrary undecodable bytes to be round-tripped through it".

So, to get FilePaths from eg, git ls-files, set the Handle that is reading
from git to use this encoding. Then things basically just work.

However, I have not found a way to make Text read using this encoding.
Text really does assume unicode. So I had to switch back to using String
when reading/writing data to git. Which is a pity, because it's some
percent slower, but at least it works.

Note that stdout and stderr also have to be set to this encoding, or
printing out filenames that contain undecodable bytes causes a crash.
IMHO this is a misfeature in ghc, that the user can pass you a filename,
which you can readFile, etc, but that default, putStr of filename may
cause a crash!

Git.CheckAttr gave me special trouble, because the filenames I got back
from git, after feeding them in, had further encoding breakage.
Rather than try to deal with that, I just zip up the input filenames
with the attributes. Which must be returned in the same order queried
for this to work.

Also of note is an apparent GHC bug I worked around in Git.CheckAttr. It
used to forkProcess and feed git from the child process.  Unfortunatly,
after this forkProcess, accessing the `files` variable from the parent
returns []. Not the value that was passed into the function. This screams
of a bad bug, that's clobbering a variable, but for now I just avoid
forkProcess there to work around it. That forkProcess was itself only added
because of a ghc bug, #624389. I've confirmed that the test case for that
bug doesn't reproduce it with ghc 7.4. So that's ok, except for the new ghc
bug I have not isolated and reported. Why does this simple bit of code
magnet the ghc bugs? :)

Also, the symlink touching code is currently broken, when used on utf-8
filenames in a non-utf-8 locale, or probably on any filename containing
undecodable bytes, and I temporarily commented it out.
2012-02-03 16:23:20 -04:00
..
Base64.hs rename 2011-07-05 20:24:10 -04:00
CopyFile.hs remove Utility.Conditional and use IfElse 2012-01-24 16:22:07 -04:00
DataUnits.hs hslint 2011-12-09 01:57:13 -04:00
Directory.hs remove Utility.Conditional and use IfElse 2012-01-24 16:22:07 -04:00
Dot.hs finished hlint pass 2011-07-15 12:47:14 -04:00
FileMode.hs make unused check branches and tags too 2011-09-28 16:43:10 -04:00
Format.hs rename readMaybe to readish 2012-01-23 17:00:10 -04:00
Gpg.hs don't use GPG_AGENT_INFO to force batch mode in test suite 2012-01-09 18:19:29 -04:00
JSONStream.hs go go gadget hlint 2011-09-20 23:24:48 -04:00
Matcher.hs go go gadget hlint 2011-09-20 23:24:48 -04:00
Misc.hs support all filename encodings with ghc 7.4 2012-02-03 16:23:20 -04:00
Monad.hs treak 2012-01-21 02:49:32 -04:00
PartialPrelude.hs rename readMaybe to readish 2012-01-23 17:00:10 -04:00
Path.hs a few things available elsewhere... 2012-01-23 16:57:45 -04:00
RsyncFile.hs Avoid excessive escaping for rsync special remotes that are not accessed over ssh. 2011-11-18 12:53:48 -04:00
SafeCommand.hs add safeSystem 2011-11-09 17:28:35 -04:00
State.hs switch to the strict state monad 2012-01-29 22:55:06 -04:00
StatFS.hsc Add a sanity check for bad StatFS results. 2012-01-14 17:17:20 -04:00
TempFile.hs treak 2012-01-21 02:49:32 -04:00
Touch.hsc go go gadget hlint 2011-09-20 23:24:48 -04:00
Url.hs Added remote.name.annex-web-options configuration setting, which can be used to provide parameters to whichever of wget or curl git-annex uses (depends on which is available, but most of their important options suitable for use here are the same). 2012-01-02 14:20:20 -04:00