diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-16 21:03:25 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-16 21:03:25 -0400 |
commit | b02a3b3f5b264ca12fcbf225db3c3ddd341ac51a (patch) | |
tree | 0a5c4ffb859db849d5b454ae098aa08cd6c227ba /Core.hs | |
parent | 96347a25a26d01ae4814e9eeb44e7c82a68fb560 (diff) |
add fix subcommand
Diffstat (limited to 'Core.hs')
-rw-r--r-- | Core.hs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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 |