summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-03 16:40:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-03 16:40:55 -0400
commitb5b78f26ecabdb74c05f8200de5f9d054da5cbae (patch)
treec7a914c0799a1606774a4653456b9033174e4d35 /Command
parentb88637fff10d4d845404882e4ec95cfc071dcac0 (diff)
fix up commands that are trouble on bare repos
Most will just abort. init does a basic init and gives a command to run elsewhere to finish it.
Diffstat (limited to 'Command')
-rw-r--r--Command/DropUnused.hs2
-rw-r--r--Command/FromKey.hs3
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/Init.hs16
-rw-r--r--Command/Unused.hs2
5 files changed, 16 insertions, 9 deletions
diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index 63216ce4f..594564cb7 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -29,7 +29,7 @@ seek = [withStrings start]
{- Drops unused content by number. -}
start :: CommandStartString
-start s = do
+start s = notBareRepo $ do
m <- readUnusedLog
case M.lookup s m of
Nothing -> return Nothing
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index d16eff846..717d528bc 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -27,9 +27,8 @@ command = [Command "fromkey" paramPath seek
seek :: [CommandSeek]
seek = [withFilesMissing start]
-{- Adds a file pointing at a manually-specified key -}
start :: CommandStartString
-start file = do
+start file = notBareRepo $ do
key <- cmdlineKey
inbackend <- Backend.hasKey key
unless inbackend $ error $
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index f8c957053..76d0e38b4 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -27,7 +27,7 @@ seek :: [CommandSeek]
seek = [withAttrFilesInGit "annex.numcopies" start]
start :: CommandStartAttrFile
-start (file, attr) = isAnnexed file $ \(key, backend) -> do
+start (file, attr) = notBareRepo $ isAnnexed file $ \(key, backend) -> do
showStart "fsck" file
return $ Just $ perform key file backend numcopies
where
diff --git a/Command/Init.hs b/Command/Init.hs
index 1074d100e..509c9e51c 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -41,11 +41,19 @@ perform :: String -> CommandPerform
perform description = do
g <- Annex.gitRepo
u <- getUUID g
- describeUUID u description
setVersion
- liftIO $ gitAttributesWrite g
- gitPreCommitHookWrite g
- return $ Just cleanup
+ if Git.repoIsLocalBare g
+ then do
+ showLongNote $
+ "This is a bare repository, so its description cannot be committed.\n" ++
+ "To record the description, run this command in a clone of this repository:\n" ++
+ " git annex describe " ++ (show u) ++ " '" ++ description ++ "'\n\n"
+ return $ Just $ return True
+ else do
+ describeUUID u description
+ liftIO $ gitAttributesWrite g
+ gitPreCommitHookWrite g
+ return $ Just cleanup
cleanup :: CommandCleanup
cleanup = do
diff --git a/Command/Unused.hs b/Command/Unused.hs
index 67a227237..9f3881d59 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -32,7 +32,7 @@ seek = [withNothing start]
{- Finds unused content in the annex. -}
start :: CommandStartNothing
-start = do
+start = notBareRepo $ do
showStart "unused" ""
return $ Just perform