relative symlink to annexed file
This commit is contained in:
parent
14d7b2ac13
commit
67ae9d7fa1
3 changed files with 12 additions and 9 deletions
2
Annex.hs
2
Annex.hs
|
@ -59,7 +59,7 @@ annexFile state file = do
|
|||
let dest = annexLocation state backend key
|
||||
createDirectoryIfMissing True (parentDir dest)
|
||||
renameFile file dest
|
||||
createSymbolicLink dest file
|
||||
createSymbolicLink (annexLocationRelative state backend key) file
|
||||
gitRun (repo state) ["add", file]
|
||||
gitRun (repo state) ["commit", "-m",
|
||||
("git-annex annexed " ++ file), file]
|
||||
|
|
10
GitRepo.hs
10
GitRepo.hs
|
@ -98,14 +98,12 @@ gitAttributes repo = assertlocal repo $ do
|
|||
then (top repo) ++ "/info/.gitattributes"
|
||||
else (top repo) ++ "/.gitattributes"
|
||||
|
||||
{- Path to a repository's .git directory.
|
||||
- (For a bare repository, that is the root of the repository.)
|
||||
- TODO: support GIT_DIR -}
|
||||
{- Path to a repository's .git directory, relative to its topdir. -}
|
||||
gitDir :: GitRepo -> String
|
||||
gitDir repo = assertlocal repo $
|
||||
if (bare repo)
|
||||
then top repo
|
||||
else top repo ++ "/.git"
|
||||
then ""
|
||||
else ".git"
|
||||
|
||||
{- Path to a repository's --work-tree. -}
|
||||
gitWorkTree :: GitRepo -> FilePath
|
||||
|
@ -130,7 +128,7 @@ gitRelative repo file = drop (length absrepo) absfile
|
|||
gitCommandLine :: GitRepo -> [String] -> [String]
|
||||
gitCommandLine repo params = assertlocal repo $
|
||||
-- force use of specified repo via --git-dir and --work-tree
|
||||
["--git-dir="++(gitDir repo), "--work-tree="++(top repo)] ++ params
|
||||
["--git-dir="++(top repo)++"/"++(gitDir repo), "--work-tree="++(top repo)] ++ params
|
||||
|
||||
{- Runs git in the specified repo. -}
|
||||
gitRun :: GitRepo -> [String] -> IO ()
|
||||
|
|
|
@ -5,7 +5,8 @@ module Locations (
|
|||
gitStateDir,
|
||||
stateLoc,
|
||||
keyFile,
|
||||
annexLocation
|
||||
annexLocation,
|
||||
annexLocationRelative
|
||||
) where
|
||||
|
||||
import Data.String.Utils
|
||||
|
@ -28,6 +29,10 @@ keyFile key = replace "/" "&s" $ replace "&" "&a" key
|
|||
- .git/annex/<backend>/<key> ; this allows deriving the key and backend
|
||||
- by looking at the symlink to it. -}
|
||||
annexLocation :: State -> Backend -> Key -> FilePath
|
||||
annexLocation state backend key =
|
||||
annexLocation state backend key =
|
||||
(gitWorkTree $ repo state) ++ "/" ++
|
||||
(annexLocationRelative state backend key)
|
||||
annexLocationRelative :: State -> Backend -> Key -> FilePath
|
||||
annexLocationRelative state backend key =
|
||||
gitDir (repo state) ++ "/annex/" ++ (name backend) ++
|
||||
"/" ++ (keyFile key)
|
||||
|
|
Loading…
Reference in a new issue