summaryrefslogtreecommitdiff
path: root/Core.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-16 21:03:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-16 21:03:25 -0400
commitb02a3b3f5b264ca12fcbf225db3c3ddd341ac51a (patch)
tree0a5c4ffb859db849d5b454ae098aa08cd6c227ba /Core.hs
parent96347a25a26d01ae4814e9eeb44e7c82a68fb560 (diff)
add fix subcommand
Diffstat (limited to 'Core.hs')
-rw-r--r--Core.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Core.hs b/Core.hs
index 5f5cba295..021595f8b 100644
--- a/Core.hs
+++ b/Core.hs
@@ -6,12 +6,14 @@ import Maybe
import System.IO
import System.Directory
import Control.Monad.State (liftIO)
+import System.Path
import Types
import Locations
import UUID
import qualified GitRepo as Git
import qualified Annex
+import Utility
{- Sets up a git repo for git-annex. -}
startup :: [Flag] -> Annex ()
@@ -81,3 +83,14 @@ gitAdd file commitmessage = do
then liftIO $ Git.run g ["commit", "-m",
(fromJust commitmessage), file]
else return ()
+
+{- Calculates the relative path to use to link a file to a key. -}
+calcGitLink :: FilePath -> Key -> Annex FilePath
+calcGitLink file key = do
+ g <- Annex.gitRepo
+ cwd <- liftIO $ getCurrentDirectory
+ let absfile = case (absNormPath cwd file) of
+ Just f -> f
+ Nothing -> error $ "unable to normalize " ++ file
+ return $ (relPathDirToDir (parentDir absfile) (Git.workTree g)) ++
+ annexLocationRelative g key