drop incomplete bare repo support

Added a bug about it.

Now git annex move --from works fully
This commit is contained in:
Joey Hess 2010-10-25 17:31:07 -04:00
parent 1aa19422ac
commit 8beed17168
3 changed files with 34 additions and 28 deletions

View file

@ -28,22 +28,22 @@ gitStateDir repo = (Git.workTree repo) ++ "/" ++ stateLoc
- <backend:fragment> - <backend:fragment>
- -
- That allows deriving the key and backend by looking at the symlink to it. - That allows deriving the key and backend by looking at the symlink to it.
-
- Note that even if the repo is a bare repo, the annex is put in a .git
- sub
-} -}
annexLocation :: Git.Repo -> Key -> FilePath annexLocation :: Git.Repo -> Key -> FilePath
annexLocation r key = annexLocation r key =
(Git.workTree r) ++ "/" ++ (annexLocationRelative r key) (Git.workTree r) ++ "/" ++ (annexLocationRelative r key)
{- Annexed file's location relative to git's working tree. -} {- Annexed file's location relative to git's working tree.
-
- Note: Assumes repo is NOT bare.-}
annexLocationRelative :: Git.Repo -> Key -> FilePath annexLocationRelative :: Git.Repo -> Key -> FilePath
annexLocationRelative r key = Git.dir r ++ "/annex/" ++ (keyFile key) annexLocationRelative r key = ".git/annex/" ++ (keyFile key)
{- .git-annex/tmp is used for temp files {- .git-annex/tmp is used for temp files
-} -
- Note: Assumes repo is NOT bare. -}
annexTmpLocation :: Git.Repo -> FilePath annexTmpLocation :: Git.Repo -> FilePath
annexTmpLocation r = (Git.workTree r) ++ "/" ++ Git.dir r ++ "/annex/tmp/" annexTmpLocation r = (Git.workTree r) ++ ".git/annex/tmp/"
{- Converts a key into a filename fragment. {- Converts a key into a filename fragment.
- -

View file

@ -188,27 +188,19 @@ tryGitConfigRead r = do
{- Tries to copy a key's content from a remote to a file. -} {- Tries to copy a key's content from a remote to a file. -}
copyFromRemote :: Git.Repo -> Key -> FilePath -> Annex Bool copyFromRemote :: Git.Repo -> Key -> FilePath -> Annex Bool
copyFromRemote r key file = do copyFromRemote r key file = do
-- annexLocation needs the git config to have been read for a remote, Core.showNote $ "copying from " ++ (Git.repoDescribe r) ++ "..."
-- so do that now if it hasn't been already if (not $ Git.repoIsUrl r)
result <- tryGitConfigRead r then getlocal
case (result) of else if (Git.repoIsSsh r)
Left err -> return False then getssh
Right from -> copy from else error "copying from non-ssh repo not supported"
where where
copy from = do getlocal = liftIO $ boolSystem "cp" ["-a", location, file]
Core.showNote $ "copying from " ++ (Git.repoDescribe from) ++ "..." getssh = do
if (not $ Git.repoIsUrl from) liftIO $ putStrLn "" -- make way for scp progress bar
then getlocal liftIO $ boolSystem "scp" [sshlocation, file]
else if (Git.repoIsSsh from) location = annexLocation r key
then getssh sshlocation = (Git.urlHost r) ++ ":" ++ location
else error "copying from non-ssh repo not supported"
where
getlocal = liftIO $ boolSystem "cp" ["-a", location, file]
getssh = do
liftIO $ putStrLn "" -- make way for scp progress bar
liftIO $ boolSystem "scp" [sshlocation, file]
location = annexLocation from key
sshlocation = (Git.urlHost from) ++ ":" ++ location
{- Tries to copy a key's content to a remote. -} {- Tries to copy a key's content to a remote. -}
copyToRemote :: Git.Repo -> Key -> Annex Bool copyToRemote :: Git.Repo -> Key -> Annex Bool
@ -255,7 +247,7 @@ updateRemoteLogStatus r key = do
-- TODO: remote log locking -- TODO: remote log locking
let mergecmd = "cat >> " ++ (shellEscape $ logFile r key) ++ " && " ++ let mergecmd = "cat >> " ++ (shellEscape $ logFile r key) ++ " && " ++
"cd " ++ (shellEscape $ Git.workTree r) ++ " && " ++ "cd " ++ (shellEscape $ Git.workTree r) ++ " && " ++
"git add " ++ (shellEscape $ gitStateDir r) "git add " ++ (shellEscape $ stateLoc)
let shellcmd = if (not $ Git.repoIsUrl r) let shellcmd = if (not $ Git.repoIsUrl r)
then pOpen WriteToPipe "sh" ["-c", mergecmd] then pOpen WriteToPipe "sh" ["-c", mergecmd]
else if (Git.repoIsSsh r) else if (Git.repoIsSsh r)

View file

@ -0,0 +1,14 @@
It would be nice if git-annex could be used in bare git repos.
However, that is not currently supported. Problems include:
* git-annex often does not read a git repo's config before touching it,
so it doesn't know if the repo is bare or not
(reading the config when operating on ssh repos would be a pain and SLOW;
I had some of that code in as of 1aa19422ac8748eeff219ac4f46df166dae783c5,
but ripped it all out)
* .. which results in creating `.git/annex` in a bare repo, which mightily
confuses git (so it will complain that the bare repo is not
a git repo at all!)
* `.git-annex/` needs to have state recorded to it and committed, and that
is not possible with a bare repo. (If [[todo/branching]] were done,
that might be fixed.)