git-annex/Command
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
..
Add.hs support all filename encodings with ghc 7.4 2012-02-03 16:23:20 -04:00
AddUrl.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
ConfigList.hs clean up read/show abuse 2011-11-08 00:17:54 -04:00
Copy.hs tweak 2012-01-06 10:57:57 -04:00
Dead.hs add 2011-12-02 19:22:43 -04:00
Describe.hs lint 2011-11-11 01:52:58 -04:00
Drop.hs fsck --from 2012-01-19 15:24:05 -04:00
DropKey.hs inverted logic 2011-12-09 13:38:28 -04:00
DropUnused.hs tweak 2012-01-06 10:57:57 -04:00
Find.hs tweak 2012-01-06 10:57:57 -04:00
Fix.hs type alias cleanup 2011-12-31 04:11:58 -04:00
FromKey.hs lint 2011-11-11 01:52:58 -04:00
Fsck.hs fsck --from remote --fast 2012-01-20 13:23:11 -04:00
Get.hs fsck --from remote --fast 2012-01-20 13:23:11 -04:00
InAnnex.hs safer inannex checking 2011-11-09 18:33:15 -04:00
Init.hs init: When run in an already initalized repository, and without a description specified, don't delete the old description. 2011-11-12 15:42:52 -04:00
InitRemote.hs type alias cleanup 2011-12-31 04:11:58 -04:00
Lock.hs clean up check selection code 2011-10-29 15:19:05 -04:00
Log.hs log: Add --gource mode, which generates output usable by gource. 2012-01-07 18:18:09 -04:00
Map.hs reorg 2012-01-10 15:29:10 -04:00
Merge.hs clean up check selection code 2011-10-29 15:19:05 -04:00
Migrate.hs type alias cleanup 2011-12-31 04:11:58 -04:00
Move.hs fsck --from remote --fast 2012-01-20 13:23:11 -04:00
PreCommit.hs better limiting of start actions to only run whenAnnexed 2011-11-10 23:45:14 -04:00
RecvKey.hs Avoid repeated location log commits when a remote is receiving files. 2012-01-28 15:41:52 -04:00
Reinject.hs type alias cleanup 2011-12-31 04:11:58 -04:00
Semitrust.hs clean up check selection code 2011-10-29 15:19:05 -04:00
SendKey.hs add support for using hashDirLower in addition to hashDirMixed 2011-11-28 22:43:51 -04:00
Status.hs switch to the strict state monad 2012-01-29 22:55:06 -04:00
Sync.hs look up --to and --from remote names only once 2012-01-06 04:06:13 -04:00
Trust.hs clean up check selection code 2011-10-29 15:19:05 -04:00
Unannex.hs type alias cleanup 2011-12-31 04:11:58 -04:00
Uninit.hs support all filename encodings with ghc 7.4 2012-02-03 16:23:20 -04:00
Unlock.hs type alias cleanup 2011-12-31 04:11:58 -04:00
Untrust.hs clean up check selection code 2011-10-29 15:19:05 -04:00
Unused.hs support all filename encodings with ghc 7.4 2012-02-03 16:23:20 -04:00
Upgrade.hs clean up check selection code 2011-10-29 15:19:05 -04:00
Version.hs When not run in a git repository, git-annex can still display a usage message, and "git annex version" even works. 2011-11-16 00:49:09 -04:00
Whereis.hs break module dependancy loop 2012-01-10 13:32:38 -04:00