avoid logging to location log when in a bare repo

This assumes that changes to content in bare repos are made from some
non-bare repo, and that the location log is updated on that side.

That's true for move --from and move --to.

It's *not* true for dropkey and setkey and recvkey. But those are plumbing
level commands, so I guess it's ok to assume that someone running those
in a bare repo knows what they're doing. And git-annex-shell is used to
run those, and if the bare repo is non-local, it needs to be able to use
them even though they cannot update the location log. So this seems
unavoidable.
This commit is contained in:
Joey Hess 2011-03-03 15:22:53 -04:00
parent d25a854085
commit 9f20aee219
2 changed files with 16 additions and 5 deletions

View file

@ -51,6 +51,11 @@ showAction :: Bool -> FilePath -> Annex ()
showAction True file = showStart "move" file showAction True file = showStart "move" file
showAction False file = showStart "copy" file showAction False file = showStart "copy" file
{- Used to log a change in a remote's having a key. The change is logged
- in the local repo, not on the remote. The process of transferring the
- key to the remote, or removing the key from it *may* log the change
- on the remote, but this cannot be relied on. For example, it's not done
- for bare repos. -}
remoteHasKey :: Git.Repo -> Key -> Bool -> Annex () remoteHasKey :: Git.Repo -> Key -> Bool -> Annex ()
remoteHasKey remote key present = do remoteHasKey remote key present = do
g <- Annex.gitRepo g <- Annex.gitRepo

View file

@ -23,7 +23,7 @@ import System.IO.Error (try)
import System.Directory import System.Directory
import Control.Monad.State (liftIO) import Control.Monad.State (liftIO)
import System.Path import System.Path
import Control.Monad (when, filterM) import Control.Monad (when, unless, filterM)
import System.Posix.Files import System.Posix.Files
import System.FilePath import System.FilePath
@ -54,13 +54,19 @@ calcGitLink file key = do
return $ relPathDirToDir (parentDir absfile) return $ relPathDirToDir (parentDir absfile)
(Git.workTree g) </> ".git" </> annexLocation key (Git.workTree g) </> ".git" </> annexLocation key
{- Updates the LocationLog when a key's presence changes. -} {- Updates the LocationLog when a key's presence changes.
-
- Note that the LocationLog is not updated in bare repositories.
- Operations that change a bare repository should be done from
- a non-bare repository, and the LocationLog in that repository be
- updated instead. -}
logStatus :: Key -> LogStatus -> Annex () logStatus :: Key -> LogStatus -> Annex ()
logStatus key status = do logStatus key status = do
g <- Annex.gitRepo g <- Annex.gitRepo
u <- getUUID g unless (Git.repoIsLocalBare g) $ do
logfile <- liftIO $ logChange g key u status u <- getUUID g
Annex.queue "add" [Param "--"] logfile logfile <- liftIO $ logChange g key u status
Annex.queue "add" [Param "--"] logfile
{- Runs an action, passing it a temporary filename to download, {- Runs an action, passing it a temporary filename to download,
- and if the action succeeds, moves the temp file into - and if the action succeeds, moves the temp file into