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
|
let dest = annexLocation state backend key
|
||||||
createDirectoryIfMissing True (parentDir dest)
|
createDirectoryIfMissing True (parentDir dest)
|
||||||
renameFile file dest
|
renameFile file dest
|
||||||
createSymbolicLink dest file
|
createSymbolicLink (annexLocationRelative state backend key) file
|
||||||
gitRun (repo state) ["add", file]
|
gitRun (repo state) ["add", file]
|
||||||
gitRun (repo state) ["commit", "-m",
|
gitRun (repo state) ["commit", "-m",
|
||||||
("git-annex annexed " ++ file), file]
|
("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"
|
then (top repo) ++ "/info/.gitattributes"
|
||||||
else (top repo) ++ "/.gitattributes"
|
else (top repo) ++ "/.gitattributes"
|
||||||
|
|
||||||
{- Path to a repository's .git directory.
|
{- Path to a repository's .git directory, relative to its topdir. -}
|
||||||
- (For a bare repository, that is the root of the repository.)
|
|
||||||
- TODO: support GIT_DIR -}
|
|
||||||
gitDir :: GitRepo -> String
|
gitDir :: GitRepo -> String
|
||||||
gitDir repo = assertlocal repo $
|
gitDir repo = assertlocal repo $
|
||||||
if (bare repo)
|
if (bare repo)
|
||||||
then top repo
|
then ""
|
||||||
else top repo ++ "/.git"
|
else ".git"
|
||||||
|
|
||||||
{- Path to a repository's --work-tree. -}
|
{- Path to a repository's --work-tree. -}
|
||||||
gitWorkTree :: GitRepo -> FilePath
|
gitWorkTree :: GitRepo -> FilePath
|
||||||
|
@ -130,7 +128,7 @@ gitRelative repo file = drop (length absrepo) absfile
|
||||||
gitCommandLine :: GitRepo -> [String] -> [String]
|
gitCommandLine :: GitRepo -> [String] -> [String]
|
||||||
gitCommandLine repo params = assertlocal repo $
|
gitCommandLine repo params = assertlocal repo $
|
||||||
-- force use of specified repo via --git-dir and --work-tree
|
-- 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. -}
|
{- Runs git in the specified repo. -}
|
||||||
gitRun :: GitRepo -> [String] -> IO ()
|
gitRun :: GitRepo -> [String] -> IO ()
|
||||||
|
|
|
@ -5,7 +5,8 @@ module Locations (
|
||||||
gitStateDir,
|
gitStateDir,
|
||||||
stateLoc,
|
stateLoc,
|
||||||
keyFile,
|
keyFile,
|
||||||
annexLocation
|
annexLocation,
|
||||||
|
annexLocationRelative
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.String.Utils
|
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
|
- .git/annex/<backend>/<key> ; this allows deriving the key and backend
|
||||||
- by looking at the symlink to it. -}
|
- by looking at the symlink to it. -}
|
||||||
annexLocation :: State -> Backend -> Key -> FilePath
|
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) ++
|
gitDir (repo state) ++ "/annex/" ++ (name backend) ++
|
||||||
"/" ++ (keyFile key)
|
"/" ++ (keyFile key)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue