summaryrefslogtreecommitdiff
path: root/Annex/Locations.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-16 17:05:42 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-16 17:18:33 -0400
commit26e4d57a9537ea3ae0c3c3b6601ee19bdd5bf50b (patch)
tree9891b572befbc1e44b2179e6c5a9f48c96aa3a80 /Annex/Locations.hs
parentbb482c2f54c38a8b1d08ed7762e50ae46ed1bbac (diff)
adjust: Add --fix adjustment, which is useful when the git directory is in a nonstandard place.
Diffstat (limited to 'Annex/Locations.hs')
-rw-r--r--Annex/Locations.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/Annex/Locations.hs b/Annex/Locations.hs
index bdd603d94..a19560682 100644
--- a/Annex/Locations.hs
+++ b/Annex/Locations.hs
@@ -15,6 +15,7 @@ module Annex.Locations (
gitAnnexLocation,
gitAnnexLocationDepth,
gitAnnexLink,
+ gitAnnexLinkCanonical,
gitAnnexContentLock,
gitAnnexMapping,
gitAnnexInodeCache,
@@ -80,6 +81,7 @@ import Types.UUID
import Types.GitConfig
import Types.Difference
import qualified Git
+import qualified Git.Types as Git
import Git.FilePath
import Annex.DirHashes
import Annex.Fixup
@@ -182,6 +184,20 @@ gitAnnexLink file key r config = do
| otherwise = Git.localGitDir r
whoops = error $ "unable to normalize " ++ file
+{- Calculates a symlink target as would be used in a typical git
+ - repository, with .git in the top of the work tree. -}
+gitAnnexLinkCanonical :: FilePath -> Key -> Git.Repo -> GitConfig -> IO FilePath
+gitAnnexLinkCanonical file key r config = gitAnnexLink file key r' config'
+ where
+ r' = case r of
+ Git.Repo { Git.location = l@Git.Local { Git.worktree = Just wt } } ->
+ r { Git.location = l { Git.gitdir = wt </> ".git" } }
+ _ -> r
+ config' = config
+ { annexCrippledFileSystem = False
+ , coreSymlinks = True
+ }
+
{- File used to lock a key's content. -}
gitAnnexContentLock :: Key -> Git.Repo -> GitConfig -> IO FilePath
gitAnnexContentLock key r config = do