prevent trust commands from trying to do things in a bare repo

Since they need to stage changes, they would actually, if allowed to run,
succeed, but wipe out existing trust.log content.
This commit is contained in:
Joey Hess 2011-03-03 16:22:53 -04:00
parent a9d0538da5
commit b88637fff1
5 changed files with 11 additions and 7 deletions

View file

@ -10,7 +10,7 @@ module Command where
import Control.Monad.State (liftIO) import Control.Monad.State (liftIO)
import System.Directory import System.Directory
import System.Posix.Files import System.Posix.Files
import Control.Monad (filterM, liftM) import Control.Monad (filterM, liftM, when)
import System.Path.WildMatch import System.Path.WildMatch
import Text.Regex.PCRE.Light.Char8 import Text.Regex.PCRE.Light.Char8
import Data.List import Data.List
@ -104,6 +104,13 @@ isAnnexed file a = do
Just v -> a v Just v -> a v
Nothing -> return Nothing Nothing -> return Nothing
notBareRepo :: Annex a -> Annex a
notBareRepo a = do
g <- Annex.gitRepo
when (Git.repoIsLocalBare g) $ do
error "You cannot run this subcommand in a bare repository."
a
{- These functions find appropriate files or other things based on a {- These functions find appropriate files or other things based on a
user's parameters, and run a specified action on them. -} user's parameters, and run a specified action on them. -}
withFilesInGit :: CommandSeekStrings withFilesInGit :: CommandSeekStrings

View file

@ -22,7 +22,7 @@ seek :: [CommandSeek]
seek = [withString start] seek = [withString start]
start :: CommandStartString start :: CommandStartString
start name = do start name = notBareRepo $ do
showStart "semitrust" name showStart "semitrust" name
Remotes.readConfigs Remotes.readConfigs
r <- Remotes.byName name r <- Remotes.byName name

View file

@ -22,7 +22,7 @@ seek :: [CommandSeek]
seek = [withString start] seek = [withString start]
start :: CommandStartString start :: CommandStartString
start name = do start name = notBareRepo $ do
showStart "trust" name showStart "trust" name
Remotes.readConfigs Remotes.readConfigs
r <- Remotes.byName name r <- Remotes.byName name

View file

@ -22,7 +22,7 @@ seek :: [CommandSeek]
seek = [withString start] seek = [withString start]
start :: CommandStartString start :: CommandStartString
start name = do start name = notBareRepo $ do
showStart "untrust" name showStart "untrust" name
Remotes.readConfigs Remotes.readConfigs
r <- Remotes.byName name r <- Remotes.byName name

View file

@ -19,12 +19,9 @@ Known to work ok:
There are a few caveats to keep in mind: There are a few caveats to keep in mind:
* Using non-local bare repositories is not tested and probably broken.
* `git annex init` can be run in a bare repository, but it cannot * `git annex init` can be run in a bare repository, but it cannot
store the name you gave the repository in .git-annex/uuid.log (because store the name you gave the repository in .git-annex/uuid.log (because
the bare repository has no such file to commit to). the bare repository has no such file to commit to).
* `git annex trust` cannot be used in a bare repository, and currently
does something pointless. Same for `untrust` and `semitrust`.
* `git annex fromkey` does something pointless in a bare repository. * `git annex fromkey` does something pointless in a bare repository.
* `git annex fsck` cannot detect any problems in a bare repository. * `git annex fsck` cannot detect any problems in a bare repository.
* `git annex unused` will think everything stored in a bare repository * `git annex unused` will think everything stored in a bare repository