From f4bf444ae0933f80b4ec1849ea1c44da43008499 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Mon, 28 Nov 2011 22:47:11 -0400
Subject: [PATCH] store content in hashDirLower directories in bare
 repositories

When storing content in bare repositories, use the hashDirLower
directories. Bare repositories can be on USB drives, which might
use the FAT filesystem, and fall afoul of recent bugs in linux's handling
of mixed case on FAT. Using hashDirLower avoids that.
---
 Locations.hs                                              | 5 ++++-
 debian/changelog                                          | 8 ++++++--
 ...nsitivity_on_FAT.mdwn => case_sensitivity_on_FAT.mdwn} | 3 ++-
 3 files changed, 12 insertions(+), 4 deletions(-)
 rename doc/bugs/{directory_remote_and_case_sensitivity_on_FAT.mdwn => case_sensitivity_on_FAT.mdwn} (95%)

diff --git a/Locations.hs b/Locations.hs
index 425e4fdcf9..fb5ee517ee 100644
--- a/Locations.hs
+++ b/Locations.hs
@@ -75,7 +75,10 @@ annexLocations key = [using hashDirMixed, using hashDirLower]
 gitAnnexLocation :: Key -> Git.Repo -> IO FilePath
 gitAnnexLocation key r
 	| Git.repoIsLocalBare r =
-		go (Git.workTree r) $ annexLocations key
+		-- bare repositories default to hashDirLower for new
+		-- content, as it's more portable, so check locations
+		-- in reverse order
+		go (Git.workTree r) $ reverse $ annexLocations key
 	| otherwise =
 		go (Git.workTree r </> ".git") $ annexLocations key
 	where
diff --git a/debian/changelog b/debian/changelog
index 9cd915885c..8da74af2f7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,11 @@
 git-annex (3.20111123) UNRELEASED; urgency=low
 
-  * Put a workaround in the directory special remote for strange behavior
-    with VFAT filesystems on Linux (mounted with shortname=mixed)
+  * The VFAT filesystem on recent versions of Linux, when mounted with
+    shortname=mixed, does not get along well with git-annex's mixed case
+    .git/annex/objects hash directories. To better support it, bare
+    repositories (and the directory special remote) now store content
+    in all-lowercase hash directories. Mixed case hash directories are
+    still used for non-bare directories, which cannot be put in VFAT.
   * Flush json output, avoiding a buffering problem that could result in
     doubled output.
   * Avoid needing haskell98 and other fixes for new ghc. Thanks, Mark Wright.
diff --git a/doc/bugs/directory_remote_and_case_sensitivity_on_FAT.mdwn b/doc/bugs/case_sensitivity_on_FAT.mdwn
similarity index 95%
rename from doc/bugs/directory_remote_and_case_sensitivity_on_FAT.mdwn
rename to doc/bugs/case_sensitivity_on_FAT.mdwn
index ae653d6197..cb3424e34d 100644
--- a/doc/bugs/directory_remote_and_case_sensitivity_on_FAT.mdwn
+++ b/doc/bugs/case_sensitivity_on_FAT.mdwn
@@ -42,4 +42,5 @@ I wonder if the directory remote should use hashDirLower instead of hashDirMixed
 >> and for the even more unlikely configuration of a rsync special remote
 >> stored on VFAT. --[[Joey]] 
 
-[[!meta title="bare git repository not supported on VFAT"]]
+>>> Bare repositories now use lowercase. rsync is the only remaining
+>>> unsupported possibility. --[[Joey]]